On 04/26/14 20:35, Alexander Bluhm wrote:
>
>> /*
>> * To avoid byte-swapping the same value over and over again.
>> */
>
> FreeBSD has code matching this comment. In OpenBSD the code is
> gone and so should the comment. Of course that is unrelated to
> this diff.
>
I have removed the comment in my new diff also.
>> + /*
>> + * Construct a Router Alert option to use in outgoing packets
>> + */
>
> The * must be aligned.
>
fixed.
>> + ra->ipopt_dst.s_addr = 0;
>
> Use INADDR_ANY instead of 0 as it is an IP address.
>
fixed.
> Otherwise OK bluhm@
>
Thanks.
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 20:10:54 -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,21 @@ 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 = INADDR_ANY;
+ 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 +644,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 20:10:54 -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.