From 5ed4291f41c8f493f5cf6737e871ca1bf4e7f2a5 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Wed, 27 Dec 2017 14:54:00 +0300 Subject: ipoe: include server's mac into weight notify packet to be used as additional key when weights are equal --- accel-pppd/ctrl/ipoe/ipoe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (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 16cc65fd..ed2419fd 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -1685,7 +1685,7 @@ static int check_notify(struct ipoe_serv *serv, struct dhcpv4_packet *pack) if (!opt) return 0; - if (opt->len != 8) + if (opt->len != 8 + ETH_ALEN) return 0; if (*(uint32_t *)opt->data != htonl(ACCEL_PPP_MAGIC)) @@ -1694,8 +1694,8 @@ static int check_notify(struct ipoe_serv *serv, struct dhcpv4_packet *pack) w = htonl(*(uint32_t *)(opt->data + 4)); list_for_each_entry(ses, &serv->sessions, entry) { - if (ses->xid == pack->hdr->xid) { - if (w < ses->weight || ses->weight == 0) { + if (ses->xid == pack->hdr->xid && memcmp(pack->hdr->chaddr, ses->hwaddr, ETH_ALEN) == 0) { + if (w < ses->weight || ses->weight == 0 || (w == ses->weight && memcmp(serv->hwaddr, opt->data + 8, ETH_ALEN) < 0)) { log_debug("ipoe: terminate %s by weight %u (%u)\n", ses->ses.ifname, w, ses->weight); triton_context_call(&ses->ctx, (triton_event_func)__terminate, &ses->ses); } -- cgit v1.2.3