From: bodea Date: Wed, 5 Apr 2006 02:13:48 +0000 (+0000) Subject: set source address for DAE responses X-Git-Tag: release_2_1_17~1 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/42bf2e312dd6899d3b9e7ad59b9346f2729efda8?ds=inline;hp=62289574150587e7540b4376ca97e30f8b6215e9 set source address for DAE responses --- diff --git a/Changes b/Changes index c74edc6..bdf954f 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ -* Fri Mar 31 2006 Brendan O'Dea 2.1.17 +* Wed Apr 5 2006 Brendan O'Dea 2.1.17 - Fix IPCP length test to allow Terminate-Request (4 bytes). - Send nsctl responses back using the correct source address (thanks ltd). +- Similarly set the source for DAE responses; use bind_address when + handling forwarded packets on the master. * Thu Feb 23 2006 Brendan O'Dea 2.1.16 - Send configured magic-no in LCP EchoReq when LCP is opened. diff --git a/cluster.c b/cluster.c index 4014e81..0b595e3 100644 --- a/cluster.c +++ b/cluster.c @@ -1,6 +1,6 @@ // L2TPNS Clustering Stuff -char const *cvs_id_cluster = "$Id: cluster.c,v 1.49 2005/12/05 14:10:42 bodea Exp $"; +char const *cvs_id_cluster = "$Id: cluster.c,v 1.50 2006/04/05 02:13:48 bodea Exp $"; #include #include @@ -1655,7 +1655,11 @@ int processcluster(uint8_t *data, int size, in_addr_t addr) STAT(recv_forward); if (type == C_FORWARD_DAE) - processdae(p, s, &a, sizeof(a)); + { + struct in_addr local; + local.s_addr = config->bind_address ? config->bind_address : my_address; + processdae(p, s, &a, sizeof(a), &local); + } else processudp(p, s, &a); diff --git a/l2tpns.c b/l2tpns.c index a0c6cff..fd0fd52 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -4,7 +4,7 @@ // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced // vim: sw=8 ts=8 -char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.158 2006/04/05 01:50:33 bodea Exp $"; +char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.159 2006/04/05 02:13:48 bodea Exp $"; #include #include @@ -647,6 +647,7 @@ static void initudp(void) addr.sin_port = htons(config->radius_dae_port); daefd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); setsockopt(daefd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + setsockopt(daefd, SOL_IP, IP_PKTINFO, &on, sizeof(on)); // recvfromto if (bind(daefd, (void *) &addr, sizeof(addr)) < 0) { LOG(0, 0, 0, "Error in DAE bind: %s\n", strerror(errno)); @@ -3300,8 +3301,8 @@ static void mainloop(void) case FD_TYPE_DAE: // DAE requests alen = sizeof(addr); - s = recvfrom(daefd, buf, sizeof(buf), MSG_WAITALL, (struct sockaddr *) &addr, &alen); - if (s > 0) processdae(buf, s, &addr, alen); + s = recvfromto(daefd, buf, sizeof(buf), MSG_WAITALL, (struct sockaddr *) &addr, &alen, &local); + if (s > 0) processdae(buf, s, &addr, alen, &local); n--; break; diff --git a/l2tpns.h b/l2tpns.h index 935baf8..c964240 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -1,5 +1,5 @@ // L2TPNS Global Stuff -// $Id: l2tpns.h,v 1.110 2006/03/27 03:01:08 bodea Exp $ +// $Id: l2tpns.h,v 1.111 2006/04/05 02:13:48 bodea Exp $ #ifndef __L2TPNS_H__ #define __L2TPNS_H__ @@ -703,7 +703,7 @@ void processrad(uint8_t *buf, int len, char socket_index); void radiusretry(uint16_t r); uint16_t radiusnew(sessionidt s); void radiusclear(uint16_t r, sessionidt s); -void processdae(uint8_t *buf, int len, struct sockaddr_in *addr, int alen); +void processdae(uint8_t *buf, int len, struct sockaddr_in *addr, int alen, struct in_addr *local); // l2tpns.c diff --git a/l2tpns.spec b/l2tpns.spec index 98904ed..42b3e28 100644 --- a/l2tpns.spec +++ b/l2tpns.spec @@ -43,5 +43,5 @@ rm -rf %{buildroot} %attr(644,root,root) /usr/share/man/man[58]/* %changelog -* Fri Mar 31 2006 Brendan O'Dea 2.1.17-1 +* Wed Apr 5 2006 Brendan O'Dea 2.1.17-1 - 2.1.17 release, see /usr/share/doc/l2tpns-2.1.17/Changes diff --git a/radius.c b/radius.c index 6cb9e16..8a66da7 100644 --- a/radius.c +++ b/radius.c @@ -1,6 +1,6 @@ // L2TPNS Radius Stuff -char const *cvs_id_radius = "$Id: radius.c,v 1.47 2005/12/19 06:18:13 bodea Exp $"; +char const *cvs_id_radius = "$Id: radius.c,v 1.48 2006/04/05 02:13:48 bodea Exp $"; #include #include @@ -785,7 +785,7 @@ void radiusretry(uint16_t r) extern int daefd; -void processdae(uint8_t *buf, int len, struct sockaddr_in *addr, int alen) +void processdae(uint8_t *buf, int len, struct sockaddr_in *addr, int alen, struct in_addr *local) { int i, r_code, r_id, length, attribute_length; uint8_t *packet, attribute; @@ -1063,6 +1063,6 @@ void processdae(uint8_t *buf, int len, struct sockaddr_in *addr, int alen) LOG(3, 0, 0, "Sending DAE %s, id=%d\n", radius_code(r_code), r_id); // send DAE response - if (sendto(daefd, buf, len, MSG_DONTWAIT | MSG_NOSIGNAL, (struct sockaddr *) addr, alen) < 0) + if (sendtofrom(daefd, buf, len, MSG_DONTWAIT | MSG_NOSIGNAL, (struct sockaddr *) addr, alen, local) < 0) LOG(0, 0, 0, "Error sending DAE response packet: %s\n", strerror(errno)); }