From faf7d93f34f588e0a8b1f1acc9ab421702831dc4 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Wed, 8 Sep 2021 16:59:16 +0300 Subject: ipoe: check for local-net in arp requests --- accel-pppd/ctrl/ipoe/ipoe.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'accel-pppd/ctrl/ipoe/ipoe.c') 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; -- cgit v1.2.3