summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2021-09-08 16:59:16 +0300
committerDmitry Kozlov <xeb@mail.ru>2021-09-08 16:59:16 +0300
commitfaf7d93f34f588e0a8b1f1acc9ab421702831dc4 (patch)
tree0654ec1ee794b3d03119f5ef3f6c5af7a7228bab /accel-pppd
parent5daf0f6782b769600855f745aa0a2e514a06a8aa (diff)
downloadaccel-ppp-faf7d93f34f588e0a8b1f1acc9ab421702831dc4.tar.gz
accel-ppp-faf7d93f34f588e0a8b1f1acc9ab421702831dc4.zip
ipoe: check for local-net in arp requests
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/ctrl/ipoe/arp.c3
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c20
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.h2
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe_netlink.c2
4 files changed, 24 insertions, 3 deletions
diff --git a/accel-pppd/ctrl/ipoe/arp.c b/accel-pppd/ctrl/ipoe/arp.c
index 4f9669b2..fa6858d2 100644
--- a/accel-pppd/ctrl/ipoe/arp.c
+++ b/accel-pppd/ctrl/ipoe/arp.c
@@ -196,6 +196,9 @@ static int arp_read(struct triton_md_handler_t *h)
if (ah->ar_spa == 0)
continue;
+ if (!ipoe_check_localnet(ah->ar_spa))
+ continue;
+
t = &arp_tree[src.sll_ifindex & HASH_BITS];
parent = NULL;
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 2645fbc6..dbc3f19f 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -237,6 +237,21 @@ static void ipoe_ctx_switch(struct triton_context_t *ctx, void *arg)
log_switch(ctx, arg);
}
+int ipoe_check_localnet(in_addr_t addr)
+{
+ struct local_net *n;
+
+ if (list_empty(&local_nets))
+ return 1;
+
+ list_for_each_entry(n, &local_nets, entry) {
+ if ((addr & n->mask) == n->addr)
+ return 1;
+ }
+
+ return 0;
+}
+
static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct dhcpv4_packet *pack, struct ipoe_session **opt82_ses)
{
struct ipoe_session *ses, *res = NULL;
@@ -3731,6 +3746,9 @@ static void parse_local_net(const char *opt)
mask = 24;
}
+ mask = htonl(mask ? ~0 << (32 - mask) : 0);
+ addr = addr & mask;
+
list_for_each_entry(n, &local_nets, entry) {
if (n->addr == addr && n->mask == mask) {
n->active = 1;
@@ -3744,7 +3762,7 @@ static void parse_local_net(const char *opt)
n->active = 1;
list_add_tail(&n->entry, &local_nets);
- ipoe_nl_add_net(addr, mask);
+ ipoe_nl_add_net(addr, ntohl(mask));
return;
diff --git a/accel-pppd/ctrl/ipoe/ipoe.h b/accel-pppd/ctrl/ipoe/ipoe.h
index 933a2c99..75948b1c 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.h
+++ b/accel-pppd/ctrl/ipoe/ipoe.h
@@ -161,5 +161,7 @@ void *arpd_start(struct ipoe_serv *ipoe);
void arpd_stop(void *arp);
void arp_send(int ifindex, struct _arphdr *arph, int bc);
+int ipoe_check_localnet(in_addr_t addr);
+
#endif
diff --git a/accel-pppd/ctrl/ipoe/ipoe_netlink.c b/accel-pppd/ctrl/ipoe/ipoe_netlink.c
index e42bf34c..e7080e92 100644
--- a/accel-pppd/ctrl/ipoe/ipoe_netlink.c
+++ b/accel-pppd/ctrl/ipoe/ipoe_netlink.c
@@ -122,8 +122,6 @@ int ipoe_nl_add_net(uint32_t addr, int mask)
ghdr = NLMSG_DATA(&req.n);
ghdr->cmd = IPOE_CMD_ADD_NET;
- mask = mask ? ~0 << (32 - mask) : 0;
-
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
addattr32(nlh, 1024, IPOE_ATTR_MASK, mask);