summaryrefslogtreecommitdiff
path: root/sys/netinet/igmp.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-05-12 09:15:01 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-05-12 09:15:01 +0000
commit1cfc5a4ecea5138557a230fbab5a7699b96efe7f (patch)
treec063a819296e17c473dd810d4ee337d291ab2004 /sys/netinet/igmp.c
parent0f9289663f6ac00114d1aeb41b44f8f6991af059 (diff)
Includes a router altert option (RAO) in IGMP packets. Without this
option, required by the RFC2236, some L3 switches do not examine the packets. Based on FreeBSD's r14622 via Florian Riehm on tech@. ok bluhm@, jca@
Diffstat (limited to 'sys/netinet/igmp.c')
-rw-r--r--sys/netinet/igmp.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 5c53f557b03..0bc618ad0ab 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.c,v 1.39 2014/04/21 12:22:26 henning Exp $ */
+/* $OpenBSD: igmp.c,v 1.40 2014/05/12 09:15:00 mpi Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
@@ -103,6 +103,7 @@ int *igmpctl_vars[IGMPCTL_MAXID] = IGMPCTL_VARS;
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 ifnet *);
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 type, in_addr_t addr)
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;
}