set source address for DAE responses
authorbodea <bodea>
Wed, 5 Apr 2006 02:13:48 +0000 (02:13 +0000)
committerbodea <bodea>
Wed, 5 Apr 2006 02:13:48 +0000 (02:13 +0000)
Changes
cluster.c
l2tpns.c
l2tpns.h
l2tpns.spec
radius.c

diff --git a/Changes b/Changes
index c74edc6..bdf954f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
-* Fri Mar 31 2006 Brendan O'Dea <bod@optus.net> 2.1.17
+* Wed Apr 5 2006 Brendan O'Dea <bod@optus.net> 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 <bod@optus.net> 2.1.16
 - Send configured magic-no in LCP EchoReq when LCP is opened.
index 4014e81..0b595e3 100644 (file)
--- 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 <stdio.h>
 #include <stdlib.h>
@@ -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);
 
index a0c6cff..fd0fd52 100644 (file)
--- 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 <arpa/inet.h>
 #include <assert.h>
@@ -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;
 
index 935baf8..c964240 100644 (file)
--- 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
index 98904ed..42b3e28 100644 (file)
@@ -43,5 +43,5 @@ rm -rf %{buildroot}
 %attr(644,root,root) /usr/share/man/man[58]/*
 
 %changelog
-* Fri Mar 31 2006 Brendan O'Dea <bod@optus.net> 2.1.17-1
+* Wed Apr 5 2006 Brendan O'Dea <bod@optus.net> 2.1.17-1
 - 2.1.17 release, see /usr/share/doc/l2tpns-2.1.17/Changes
index 6cb9e16..8a66da7 100644 (file)
--- 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 <time.h>
 #include <stdio.h>
@@ -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));
 }