Hello Florian,
On 26/04/14(Sat) 22:22, Florian Riehm wrote:
> 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.
>
> [...]
Be careful next time you send a diff, this one got reformatted and I
couldn't apply it correctly ;)
Here's an updated version of your diff that adds a check in case
m_get() returns NULL (very unlikely) and since I couldn't easily
understand the two fields set to 0x00, I decided to document them.
ok?
Index: igmp.c
===================================================================
RCS file: /home/ncvs/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 5 May 2014 13:32:12 -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,34 @@ 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;
+
+ router_alert = m_get(M_DONTWAIT, MT_DATA);
+ if (router_alert == NULL) {
+ printf("%s: no mbuf\n", __func__);
+ return;
+ }
+
+ /*
+ * Construct a Router Alert option (RAO) to use in report
+ * messages as required by RFC2236. This option has the
+ * following format:
+ *
+ * | 10010100 | 00000100 | 2 octet value |
+ *
+ * where a value of "0" indicates that routers shall examine
+ * the packet.
+ */
+ ra = mtod(router_alert, struct ipoption *);
+ ra->ipopt_dst.s_addr = INADDR_ANY;
+ ra->ipopt_list[0] = IPOPT_RA;
+ ra->ipopt_list[1] = 0x04;
+ 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 +657,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: /home/ncvs/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 5 May 2014 13:32:12 -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.