Hi tech,

our IGMP packets don't contain router alert options.
According rfc 2236 (Internet Group Management Protocol, Version 2)
packets without this option have to be ignored. Some layer 3 switches
are blocking our igmp packets because of that.
The following patch is based on a FreeBSD patch long years ago:
http://svnweb.freebsd.org/base?view=revision&revision=14622

I would be happy if anybody could commit this.

Regards,

Florian


Index: igmp.c
===================================================================
RCS file: /cvs/src/sys/netinet/igmp.c,v
retrieving revision 1.39
diff -u -p -r1.39 igmp.c
--- igmp.c      21 Apr 2014 12:22:26 -0000      1.39
+++ igmp.c      26 Apr 2014 14:46:31 -0000
@@ -103,6 +103,7 @@ int *igmpctl_vars[IGMPCTL_MAXID] = IGMPC

 int            igmp_timers_are_running;
 static struct router_info *rti_head;
+static struct mbuf *router_alert;
 struct igmpstat igmpstat;

 void igmp_checktimer(struct ifnet *);
@@ -113,12 +114,24 @@ struct router_info * rti_find(struct ifn
 void
 igmp_init(void)
 {
+       struct ipoption *ra;

        /*
         * To avoid byte-swapping the same value over and over again.
         */
        igmp_timers_are_running = 0;
        rti_head = 0;
+       /*
+       * Construct a Router Alert option to use in outgoing packets
+       */
+       router_alert = m_get(M_DONTWAIT, MT_DATA);
+       ra = mtod(router_alert, struct ipoption *);
+       ra->ipopt_dst.s_addr = 0;
+       ra->ipopt_list[0] = IPOPT_RA;   /* Router Alert Option */
+       ra->ipopt_list[1] = 0x04;       /* 4 bytes long */
+       ra->ipopt_list[2] = 0x00;
+       ra->ipopt_list[3] = 0x00;
+       router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];
 }

 /* Return -1 for error. */
@@ -634,7 +647,7 @@ igmp_sendpkt(struct in_multi *inm, int t
        imo.imo_multicast_loop = 0;
 #endif /* MROUTING */

-       ip_output(m, NULL, NULL, IP_MULTICASTOPTS, &imo, NULL, 0);
+       ip_output(m, router_alert, NULL, IP_MULTICASTOPTS, &imo, NULL, 0);

        ++igmpstat.igps_snd_reports;
 }
Index: ip.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip.h,v
retrieving revision 1.14
diff -u -p -r1.14 ip.h
--- ip.h        24 Oct 2013 15:21:21 -0000      1.14
+++ ip.h        26 Apr 2014 14:46:31 -0000
@@ -150,6 +150,7 @@ struct ip {
 #define        IPOPT_LSRR              131             /* loose source route */
 #define        IPOPT_SATID             136             /* satnet id */
 #define        IPOPT_SSRR              137             /* strict source route 
*/
+#define        IPOPT_RA                148             /* router alert */

 /*
  * Offsets to fields in options other than EOL and NOP.

Reply via email to