summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/accel-ppp.conf1
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c14
-rw-r--r--accel-pppd/triton/md.c4
-rw-r--r--accel-pppd/triton/timer.c13
-rw-r--r--cmake/cpack.cmake10
-rw-r--r--drivers/ipoe/ipoe.c58
-rw-r--r--drivers/vlan_mon/vlan_mon.c37
7 files changed, 105 insertions, 32 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index a54731c..144bf1f 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -75,6 +75,7 @@ verbose=1
[pppoe]
verbose=1
+#max-starting=0
#ac-name=xxx
#service-name=yyy
#pado-delay=0
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 120e161..32dee77 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -87,6 +87,7 @@ struct iplink_arg {
long *arg1;
};
+static int conf_max_starting;
int conf_verbose;
char *conf_service_name[255];
int conf_accept_any_service;
@@ -968,6 +969,13 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return;
+ if (conf_max_starting > 0 && stat_starting >= conf_max_starting) {
+ log_warn("pppoe: Count of starting sessions > conf_max_starting, droping connection...\n");
+ return;
+
+ }
+
+
if (check_padi_limit(serv, ethhdr->h_source)) {
__sync_add_and_fetch(&stat_PADI_drop, 1);
@@ -1928,6 +1936,12 @@ static void load_config(void)
char *opt;
struct conf_sect_t *s = conf_get_section("pppoe");
+ opt = conf_get_opt("pppoe", "max-starting");
+ if (opt)
+ conf_max_starting = atoi(opt);
+ else
+ conf_max_starting = 0;
+
opt = conf_get_opt("pppoe", "verbose");
if (opt)
conf_verbose = atoi(opt);
diff --git a/accel-pppd/triton/md.c b/accel-pppd/triton/md.c
index b490d0c..9b7dd81 100644
--- a/accel-pppd/triton/md.c
+++ b/accel-pppd/triton/md.c
@@ -9,8 +9,6 @@
#include "triton_p.h"
-#include "memdebug.h"
-
extern int max_events;
static int epoll_fd;
@@ -35,7 +33,7 @@ int md_init(void)
fcntl(epoll_fd, F_SETFD, O_CLOEXEC);
- epoll_events = _malloc(max_events * sizeof(struct epoll_event));
+ epoll_events = malloc(max_events * sizeof(struct epoll_event));
if (!epoll_events) {
fprintf(stderr,"md:cann't allocate memory\n");
return -1;
diff --git a/accel-pppd/triton/timer.c b/accel-pppd/triton/timer.c
index 18599ef..744b10b 100644
--- a/accel-pppd/triton/timer.c
+++ b/accel-pppd/triton/timer.c
@@ -142,8 +142,8 @@ int __export triton_timer_add(struct triton_context_t *ctx, struct triton_timer_
}
if (fcntl(t->fd, F_SETFL, O_NONBLOCK)) {
- triton_log_error("timer: failed to set nonblocking mode: %s", strerror(errno));
- goto out_err;
+ triton_log_error("timer: failed to set nonblocking mode: %s", strerror(errno));
+ goto out_err;
}
__sync_add_and_fetch(&t->ctx->refs, 1);
@@ -165,7 +165,7 @@ int __export triton_timer_add(struct triton_context_t *ctx, struct triton_timer_
goto out_err;
}
- triton_stat.timer_count++;
+ __sync_add_and_fetch(&triton_stat.timer_count, 1);
return 0;
@@ -198,8 +198,9 @@ int __export triton_timer_mod(struct triton_timer_t *ud,int abs_time)
void __export triton_timer_del(struct triton_timer_t *ud)
{
struct _triton_timer_t *t = (struct _triton_timer_t *)ud->tpd;
- epoll_ctl(epoll_fd, EPOLL_CTL_DEL, t->fd, &t->epoll_event);
+
close(t->fd);
+
spin_lock(&t->ctx->lock);
t->ud = NULL;
list_del(&t->entry);
@@ -209,14 +210,12 @@ void __export triton_timer_del(struct triton_timer_t *ud)
}
spin_unlock(&t->ctx->lock);
- sched_yield();
-
pthread_mutex_lock(&freed_list_lock);
list_add_tail(&t->entry, &freed_list);
pthread_mutex_unlock(&freed_list_lock);
ud->tpd = NULL;
- triton_stat.timer_count--;
+ __sync_sub_and_fetch(&triton_stat.timer_count, 1);
}
diff --git a/cmake/cpack.cmake b/cmake/cpack.cmake
index d597074..0f270cf 100644
--- a/cmake/cpack.cmake
+++ b/cmake/cpack.cmake
@@ -43,7 +43,7 @@ IF(CPACK_TYPE STREQUAL Debian10)
ENDIF(CPACK_TYPE STREQUAL Debian10)
IF(CPACK_TYPE STREQUAL Ubuntu16)
- SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.24), libssl1.0.0 (>= 1.0.2t), libpcre3 (>= 8.39)")
+ SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.23), libssl1.0.0 (>= 1.0.0), libpcre3 (>= 8.39)")
INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake)
ENDIF(CPACK_TYPE STREQUAL Ubuntu16)
@@ -60,4 +60,12 @@ IF(CPACK_TYPE STREQUAL Centos7)
INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/centos/centos.cmake)
ENDIF()
+IF(CPACK_TYPE STREQUAL Centos8)
+ SET(CPACK_RPM_PACKAGE_LICENSE "GPL")
+ SET(CPACK_RPM_PACKAGE_URL "http://accel-ppp.org")
+ SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin")
+ SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.28, openssl-libs >= 1.1.1, pcre >= 8.42")
+ INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/centos/centos.cmake)
+ENDIF()
+
INCLUDE(CPack)
diff --git a/drivers/ipoe/ipoe.c b/drivers/ipoe/ipoe.c
index f3acb3f..6ac6d77 100644
--- a/drivers/ipoe/ipoe.c
+++ b/drivers/ipoe/ipoe.c
@@ -174,6 +174,10 @@ static struct genl_multicast_group ipoe_nl_mcg;
#define NETIF_F_HW_VLAN_FILTER NETIF_F_HW_VLAN_CTAG_FILTER
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+#define nla_nest_start_noflag(skb, attr) nla_nest_start(skb, attr)
+#endif
+
static inline int hash_addr(__be32 addr)
{
#ifdef __LITTLE_ENDIAN
@@ -255,8 +259,13 @@ static int check_nat_required(struct sk_buff *skb, struct net_device *link)
if (IS_ERR(rt))
return 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
if (rt->rt_gateway || (rt->dst.dev != link && rt->dst.dev != skb->dev))
r = 1;
+#else
+ if (rt->rt_gw4 || (rt->dst.dev != link && rt->dst.dev != skb->dev))
+ r = 1;
+#endif
ip_rt_put(rt);
@@ -616,7 +625,7 @@ static void ipoe_process_queue(struct work_struct *w)
}
if (report_skb) {
- ns = nla_nest_start(report_skb, id++);
+ ns = nla_nest_start_noflag(report_skb, id++);
if (!ns)
goto nl_err;
@@ -1729,7 +1738,7 @@ static int ipoe_nl_cmd_del_net(struct sk_buff *skb, struct genl_info *info)
return 0;
}
-static struct nla_policy ipoe_nl_policy[IPOE_ATTR_MAX + 1] = {
+static const struct nla_policy ipoe_nl_policy[IPOE_ATTR_MAX + 1] = {
[IPOE_ATTR_NONE] = { .type = NLA_UNSPEC, },
[IPOE_ATTR_ADDR] = { .type = NLA_U32, },
[IPOE_ATTR_PEER_ADDR] = { .type = NLA_U32, },
@@ -1741,71 +1750,93 @@ static struct nla_policy ipoe_nl_policy[IPOE_ATTR_MAX + 1] = {
[IPOE_ATTR_LINK_IFINDEX]= { .type = NLA_U32, },
};
-static struct genl_ops ipoe_nl_ops[] = {
+static const struct genl_ops ipoe_nl_ops[] = {
{
.cmd = IPOE_CMD_NOOP,
.doit = ipoe_nl_cmd_noop,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
.policy = ipoe_nl_policy,
+#endif
/* can be retrieved by unprivileged users */
},
{
.cmd = IPOE_CMD_CREATE,
.doit = ipoe_nl_cmd_create,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DELETE,
.doit = ipoe_nl_cmd_delete,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_MODIFY,
.doit = ipoe_nl_cmd_modify,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_GET,
.dumpit = ipoe_nl_cmd_dump_sessions,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
.policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_ADD_IF,
.doit = ipoe_nl_cmd_add_interface,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DEL_IF,
.doit = ipoe_nl_cmd_del_interface,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_ADD_EXCLUDE,
.doit = ipoe_nl_cmd_add_exclude,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DEL_EXCLUDE,
.doit = ipoe_nl_cmd_del_exclude,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_ADD_NET,
.doit = ipoe_nl_cmd_add_net,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
{
.cmd = IPOE_CMD_DEL_NET,
.doit = ipoe_nl_cmd_del_net,
- .policy = ipoe_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
},
};
@@ -1834,6 +1865,9 @@ static struct genl_family ipoe_nl_family = {
.mcgrps = ipoe_nl_mcgs,
.n_mcgrps = ARRAY_SIZE(ipoe_nl_mcgs),
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,2,0)
+ .policy = ipoe_nl_policy,
+#endif
};
static const struct net_device_ops ipoe_netdev_ops = {
diff --git a/drivers/vlan_mon/vlan_mon.c b/drivers/vlan_mon/vlan_mon.c
index b6476d4..271f2ff 100644
--- a/drivers/vlan_mon/vlan_mon.c
+++ b/drivers/vlan_mon/vlan_mon.c
@@ -43,6 +43,10 @@
#define vlan_tx_tag_present(skb) skb_vlan_tag_present(skb)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+#define nla_nest_start_noflag(skb, attr) nla_nest_start(skb, attr)
+#endif
+
struct vlan_dev {
unsigned int magic;
int ifindex;
@@ -198,13 +202,13 @@ static void vlan_do_notify(struct work_struct *w)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) && RHEL_MAJOR < 7
header = genlmsg_put(report_skb, 0, vlan_mon_nl_mcg.id, &vlan_mon_nl_family, 0, VLAN_MON_NOTIFY);
#else
- header = genlmsg_put(report_skb, 0, vlan_mon_nl_family.mcgrp_offset, &vlan_mon_nl_family, 0, VLAN_MON_NOTIFY);
+ header = genlmsg_put(report_skb, 0, 0, &vlan_mon_nl_family, 0, VLAN_MON_NOTIFY);
#endif
}
//pr_info("notify %i vlan %i\n", id, n->vid);
- ns = nla_nest_start(report_skb, id++);
+ ns = nla_nest_start_noflag(report_skb, id++);
if (!ns)
goto nl_err;
@@ -616,7 +620,7 @@ static int vlan_mon_nl_cmd_check_busy(struct sk_buff *skb, struct genl_info *inf
return ret;
}
-static struct nla_policy vlan_mon_nl_policy[VLAN_MON_ATTR_MAX + 1] = {
+static const struct nla_policy vlan_mon_nl_policy[VLAN_MON_ATTR_MAX + 1] = {
[VLAN_MON_ATTR_NONE] = { .type = NLA_UNSPEC, },
[VLAN_MON_ATTR_VLAN_MASK] = { .type = NLA_BINARY, .len = 4096/8 },
[VLAN_MON_ATTR_PROTO] = { .type = NLA_U16, },
@@ -624,42 +628,54 @@ static struct nla_policy vlan_mon_nl_policy[VLAN_MON_ATTR_MAX + 1] = {
[VLAN_MON_ATTR_VID] = { .type = NLA_U16, },
};
-static struct genl_ops vlan_mon_nl_ops[] = {
+static const struct genl_ops vlan_mon_nl_ops[] = {
{
.cmd = VLAN_MON_CMD_NOOP,
.doit = vlan_mon_nl_cmd_noop,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
.policy = vlan_mon_nl_policy,
+#endif
/* can be retrieved by unprivileged users */
},
{
.cmd = VLAN_MON_CMD_ADD,
.doit = vlan_mon_nl_cmd_add_vlan_mon,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_ADD_VID,
.doit = vlan_mon_nl_cmd_add_vlan_mon_vid,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_DEL,
.doit = vlan_mon_nl_cmd_del_vlan_mon,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_CHECK_BUSY,
.doit = vlan_mon_nl_cmd_check_busy,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
{
.cmd = VLAN_MON_CMD_DEL_VID,
.doit = vlan_mon_nl_cmd_del_vlan_mon_vid,
- .policy = vlan_mon_nl_policy,
.flags = GENL_ADMIN_PERM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
},
};
@@ -688,6 +704,9 @@ static struct genl_family vlan_mon_nl_family = {
.mcgrps = vlan_mon_nl_mcgs,
.n_mcgrps = ARRAY_SIZE(vlan_mon_nl_mcgs),
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,2,0)
+ .policy = vlan_mon_nl_policy,
+#endif
};
static struct packet_type vlan_pt __read_mostly = {