Hi,
The following will disregard the routing table for multicast packets
when the application chose the interface with IP_MULTICAST_IF, if not,
normal lookup will take place.
Ripd now no longer needs to explicitly add the mcast host route to
bypass the default reject to 224/4, follows the diff to remove it.
Regarding the normal lookup when IP_MULTICAST_IF wan't set, UNP
regards it as a BSD descendant behaviour, I really don't know anything
else.
I've tested it in a small setup, if someone could confirm it in a
scarier environment would be nice.
Index: netinet/in_pcb.c
===================================================================
RCS file: /cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.112
diff -d -u -p -w netinet/in_pcb.c
--- netinet/in_pcb.c 7 May 2010 13:33:16 -0000 1.112
+++ netinet/in_pcb.c 12 Jun 2010 19:18:49 -0000
@@ -819,7 +819,9 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro
}
if ((soopts & SO_DONTROUTE) == 0 && /*XXX*/
(ro->ro_rt == (struct rtentry *)0 ||
- ro->ro_rt->rt_ifp == (struct ifnet *)0)) {
+ ro->ro_rt->rt_ifp == (struct ifnet *)0) &&
+ !(IN_MULTICAST(sin->sin_addr.s_addr) &&
+ mopts && (mopts->imo_multicast_ifp != NULL))) {
/* No route yet, so try to acquire one */
ro->ro_dst.sa_family = AF_INET;
ro->ro_dst.sa_len = sizeof(struct sockaddr_in);
Index: kroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/ripd/kroute.c,v
retrieving revision 1.21
diff -d -u -p -w kroute.c
--- kroute.c 2 Jan 2009 14:40:54 -0000 1.21
+++ kroute.c 12 Jun 2010 19:19:51 -0000
@@ -97,9 +97,6 @@ RB_HEAD(kif_tree, kif_node) kit;
RB_PROTOTYPE(kif_tree, kif_node, entry, kif_compare)
RB_GENERATE(kif_tree, kif_node, entry, kif_compare)
-struct kroute kr_all_rip_routers;
-int flag_all_rip_routers = 0;
-
int
kif_init(void)
{
@@ -151,14 +148,6 @@ kr_init(int fs, u_int rdomain)
if (protect_lo() == -1)
return (-1);
- kr_all_rip_routers.prefix.s_addr = inet_addr(ALL_RIP_ROUTERS);
- kr_all_rip_routers.netmask.s_addr = htonl(INADDR_BROADCAST);
- kr_all_rip_routers.nexthop.s_addr = htonl(INADDR_LOOPBACK);
-
- kr_state.fib_sync = 1; /* force addition of multicast route */
- if (send_rtmsg(kr_state.fd, RTM_ADD, &kr_all_rip_routers) != -1)
- flag_all_rip_routers = 1;
-
kr_state.fib_sync = fs; /* now set correct sync mode */
kr_state.rdomain = rdomain;
@@ -243,11 +232,6 @@ void
kr_shutdown(void)
{
kr_fib_decouple();
-
- if (flag_all_rip_routers) {
- kr_state.fib_sync = 1; /* force removal of mulitcast route */
- (void)send_rtmsg(kr_state.fd, RTM_DELETE, &kr_all_rip_routers);
- }
kroute_clear();
kif_clear();