From 338e86560f0bb991852f977ff5376a2d9fb71b20 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Tue, 11 Jun 2013 23:01:28 +0400 Subject: ipoe: fixed mask calculation for gw-ip-address ipoe: pass router=siaddr if router was not configured by other way --- accel-pppd/ctrl/ipoe/ipoe.c | 11 +++++++---- accel-pppd/session.c | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'accel-pppd') diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index e9edd9b..ac971c4 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -112,6 +112,7 @@ struct gw_addr { struct list_head entry; in_addr_t addr; int mask; + int mask1; }; static pthread_mutex_t uc_lock = PTHREAD_MUTEX_INITIALIZER; @@ -481,14 +482,11 @@ static void find_gw_addr(struct ipoe_session *ses) struct gw_addr *a; list_for_each_entry(a, &conf_gw_addr, entry) { -#if __BYTE_ORDER == __LITTLE_ENDIAN - if ((ses->yiaddr & ((1<mask) - 1)) == (a->addr & ((1<mask) - 1))) { + if ((ntohl(ses->yiaddr) & (a->mask1)) == (ntohl(a->addr) & (a->mask1))) { ses->siaddr = a->addr; ses->mask = a->mask; return; } -#else -#endif } } @@ -547,6 +545,9 @@ static void __ipoe_session_start(struct ipoe_session *ses) ap_session_terminate(&ses->ses, TERM_NAS_ERROR, 0); return; } + + if (!ses->router) + ses->router = ses->siaddr; if (!ses->mask) ses->mask = 32; @@ -1919,6 +1920,8 @@ static void load_gw_addr(struct conf_sect_t *sect) _free(a); continue; } + + a->mask1 = ((1 << a->mask) - 1) << (32 - a->mask); list_add_tail(&a->entry, &conf_gw_addr); } } diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 380552a..f60c380 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -42,7 +42,9 @@ int __export sock6_fd; int __export urandom_fd; int __export ap_shutdown; +#if __WORDSIZE == 32 static spinlock_t seq_lock; +#endif static long long unsigned seq; static struct timespec seq_ts; -- cgit v1.2.3