Mailing List Archive

[Bug 420] ospfd binds to wrong interfaces for multicast [FreeBSD 7]
Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug
report.

http://bugzilla.quagga.net/show_bug.cgi?id=420


jeremy@vtdn.net changed:

What |Removed |Added
----------------------------------------------------------------------------
Summary|ospfd binds to wrong |ospfd binds to wrong
|interfaces for multicast |interfaces for multicast
|[FreeBSD 7/amd64] |[FreeBSD 7]




------- Additional Comments From wiwi@progon.net 2007-11-23 17:12 -------
as requested:

monitor.as34288.net> show interface
Interface bce0 is down
index 1 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface bce1 is down
index 10 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface em0 is up, line protocol detection is disabled
index 2 metric 1 mtu 1500
flags: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
inet 10.32.104.75/16 broadcast 10.32.255.255
input packets 1189, bytes 443397, dropped 0, multicast packets 592
input errors 0
output packets 742, bytes 87104, multicast packets 2
output errors 0
collisions 0
Interface em1 is down
index 3 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface em2 is down
index 4 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface em3 is up, line protocol detection is disabled
index 5 metric 1 mtu 1500
flags: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
inet 81.94.118.8/26 broadcast 81.94.118.63
input packets 51, bytes 3060, dropped 0, multicast packets 51
input errors 0
output packets 4, bytes 276, multicast packets 3
output errors 0
collisions 0
Interface em4 is down
index 6 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface em5 is down
index 7 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface em6 is down
index 8 metric 1 mtu 1500
flags: <BROADCAST,SIMPLEX,MULTICAST>
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0
Interface em7 is up, line protocol detection is disabled
index 9 metric 1 mtu 1500
flags: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
inet 81.94.118.136/26 broadcast 81.94.118.191
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 42, multicast packets 0
output errors 0
collisions 0
Interface lo0 is up, line protocol detection is disabled
index 11 metric 1 mtu 16384
flags: <UP,LOOPBACK,RUNNING,MULTICAST>
inet 127.0.0.1/8 broadcast 127.0.0.1
inet6 fe80::1/64
inet6 ::1/128 broadcast ::1
input packets 64, bytes 3572, dropped 0, multicast packets 0
input errors 0
output packets 64, bytes 3572, multicast packets 0
output errors 0
collisions 0
Interface lo1 is up, line protocol detection is disabled
index 12 metric 1 mtu 16384
flags: <UP,LOOPBACK,RUNNING,MULTICAST>
inet 81.94.118.193/32 broadcast 81.94.118.193
input packets 0, bytes 0, dropped 0, multicast packets 0
input errors 0
output packets 0, bytes 0, multicast packets 0
output errors 0
collisions 0


ospfd> sh ip ospf interface
bce0 is down
ifindex 1, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
bce1 is down
ifindex 10, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em0 is up
ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em1 is down
ifindex 3, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em2 is down
ifindex 4, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em3 is up
ifindex 5, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
Internet Address 81.94.118.8/26, Broadcast 81.94.118.63, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 81.94.118.136, Network Type BROADCAST, Cost: 1000
Transmit Delay is 1 sec, State DROther, Priority 0
No designated router on this network
No backup designated router on this network
Multicast group memberships: OSPFAllRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
Hello due in 3.925s
Neighbor Count is 0, Adjacent neighbor count is 0
em4 is down
ifindex 6, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em5 is down
ifindex 7, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em6 is down
ifindex 8, MTU 1500 bytes, BW 0 Kbit <BROADCAST,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
em7 is up
ifindex 9, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>
OSPF not enabled on this interface
lo0 is up
ifindex 11, MTU 16384 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING,MULTICAST>
OSPF not enabled on this interface
lo1 is up
ifindex 12, MTU 16384 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING,MULTICAST>
OSPF not enabled on this interface

monitor[root]:/usr/ports/net/quagga(117)# netstat -g
Link-layer Multicast Group Memberships
Group Link-layer Address Netif
01:00:5e:00:00:05 <none> em0
01:00:5e:00:00:01 <none> em0
01:00:5e:00:00:01 <none> em3
01:00:5e:00:00:01 <none> em7

IPv4 Multicast Group Memberships
Group Link-layer Address Netif
224.0.0.5 01:00:5e:00:00:05 em0
224.0.0.1 01:00:5e:00:00:01 em0
224.0.0.1 01:00:5e:00:00:01 em3
224.0.0.1 01:00:5e:00:00:01 em7
224.0.0.1 <none> lo0
224.0.0.1 <none> lo1

IPv6 Multicast Group Memberships
Group Link-layer Address Netif
ff01:b::1 <none> lo0
ff02:b::2:217e:b36c <none> lo0
ff02:b::1 <none> lo0
ff02:b::1:ff00:1 <none> lo0

------- Additional Comments From jeremy@vtdn.net 2007-11-27 06:09 -------
Changed summary to [FreeBSD 7] because this includes both AMD64 and i386, not
specific to one architecture.



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
_______________________________________________
Quagga-bugs mailing list
Quagga-bugs@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-bugs
[Bug 420] ospfd binds to wrong interfaces for multicast [FreeBSD 7] [ In reply to ]
Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug
report.

http://bugzilla.quagga.net/show_bug.cgi?id=420





------- Additional Comments From paul@dishone.st 2007-12-02 18:26 -------
Sounds like FreeBSD 7 has changed a system interface. Do we know what the change
was? Further was it intentional? (Changing a public kernel/userspace interface
is usually a bug).




------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
_______________________________________________
Quagga-bugs mailing list
Quagga-bugs@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-bugs
[Bug 420] ospfd binds to wrong interfaces for multicast [FreeBSD 7] [ In reply to ]
Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug
report.

http://bugzilla.quagga.net/show_bug.cgi?id=420





------- Additional Comments From jeremy@vtdn.net 2007-12-02 21:11 -------
I've already finished debugging this completely.

FreeBSD 7 made some fundamental changes to the multicast processing which Quagga
relies on a 'hack' in the kernel to function properly.

The specific issue seems to occur when quagga calls IP_MULTICAST_IF with an IP
address of 0.0.0.0/8. FreeBSD will default to whatever interface the default
route is (usually).

Please see comments from other users at:
http://www.nabble.com/forum/ViewPost.jtp?post=11172865&framed=y

Here's the changelog from FreeBSD source tree:
20070612:
The IPv4 multicast socket code has been considerably modified, and
moved to the file sys/netinet/in_mcast.c. Initial support for the
RFC 3678 Source-Specific Multicast Socket API has been added to
the IPv4 network stack.

Strict multicast and broadcast reception is now the default for
UDP/IPv4 sockets; the net.inet.udp.strict_mcast_mship sysctl variable
has now been removed.

The RFC 1724 hack for interface selection has been removed; the use
of the Linux-derived ip_mreqn structure with IP_MULTICAST_IF has
been added to replace it. Consumers such as routed will soon be
updated to reflect this.

These changes affect users who are running routed(8) or rdisc(8)
from the FreeBSD base system on point-to-point or unnumbered
interfaces.


My solution on my system was to edit lib/sockopt.c and remove the following code:

Remove from:
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
to
#endif


Remove:
#ifdef HAVE_BSD_STRUCT_IP_MREQ_HACK
if (ifindex)
m.s_addr = htonl(ifindex);
else
#endif


Thus making the complete function setsockopt_multicast_ipv4 looking like:
int
setsockopt_multicast_ipv4(int sock,
int optname,
struct in_addr if_addr /* required */,
unsigned int mcast_addr,
unsigned int ifindex /* optional: if non-zero, may be
used instead of if_addr */)
{

struct in_addr m;
struct ip_mreq mreq;
int ret;

m = if_addr;

switch (optname)
{
case IP_MULTICAST_IF:
return setsockopt (sock, IPPROTO_IP, optname, (void *)&m, sizeof(m));
break;

case IP_ADD_MEMBERSHIP:
case IP_DROP_MEMBERSHIP:
memset (&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr.s_addr = mcast_addr;
mreq.imr_interface = m;

ret = setsockopt (sock, IPPROTO_IP, optname, (void *)&mreq, sizeof(mreq));
if ((ret < 0) && (optname == IP_ADD_MEMBERSHIP) && (errno == EADDRINUSE))
{
/* see above: handle possible problem when interface comes back up */
char buf[2][INET_ADDRSTRLEN];
zlog_info("setsockopt_multicast_ipv4 attempting to drop and "
"re-add (fd %d, ifaddr %s, mcast %s, ifindex %u)",
sock,
inet_ntop(AF_INET, &if_addr, buf[0], sizeof(buf[0])),
inet_ntop(AF_INET, &mreq.imr_multiaddr,
buf[1], sizeof(buf[1])), ifindex);
setsockopt (sock, IPPROTO_IP, IP_DROP_MEMBERSHIP,
(void *)&mreq, sizeof(mreq));
ret = setsockopt (sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(void *)&mreq, sizeof(mreq));
}
return ret;
break;

default:
/* Can out and give an understandable error */
errno = EINVAL;
return -1;
break;
}

}




------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
_______________________________________________
Quagga-bugs mailing list
Quagga-bugs@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-bugs
[Bug 420] ospfd binds to wrong interfaces for multicast [FreeBSD 7] [ In reply to ]
Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug
report.

http://bugzilla.quagga.net/show_bug.cgi?id=420





------- Additional Comments From paul@dishone.st 2007-12-02 22:20 -------
Quagga already supports ip_mreqn, so the addition of it to FreeBSD will cause
Quagga to automatically stop using the old hack and start passing ifindex
explicitly with IP_MULTICAST_IF and IP_{ADD,DROP}_MEMBERSHIP. There's one fly in
the ointment though, which is that the current mreqn sockopt code isn't working
on FreeBSD, it doesn't result in ospfd joining to the correct interfaces.

This /seems/ to be due to the fact that, at present in FreeBSD 7 beta, only
IP_MULTICAST_IF has been extended to support mreqn. IP_ADD/DROP_MEMBERSHIP still
assumes an old ip_mreq. Quagga however is passing an ip_mreqn, leaving the
address blank and passing ifindex. FreeBSD get 0 address and thus picks the
first capable interface instead, blithely unaware that an ifindex was passed in.

I presume it is intended to complete the mreqn support in short order in FreeBSD
(for this half-implementation breaks all multicast code that detects mreqn
presence at runtime and assumes therefore that it works for ADD/DROP_MEMBERSHIP
- which it does on Linux).

If that presumption is correct, then this is a temporary bug in FreeBSD and
there's nothing to be changed in Quagga.


------- Additional Comments From i@levsha.org.ua 2007-12-12 20:56 -------
I think that this is bug in quagga: using ip_mreqn with IP_ADD/DROP_MEMBERSHIP
is linux specific hack: rfc 3678 allow only ip_mreq for IP_ADD/DROP_MEMBERSHIP.
At the same time q&#1091;&#1072;&#1075;&#1075;&#1072; only checks existence of structure ip_mreqn and think
that it can be used in IP_ADD/DROP_MEMBERSHIP.
I think that the correct solve of this problem is extending quagga configure to
check support of rfc 3678 (for example by checking existence
MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP constants) and then using
MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP instead of IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP
I have patch, which change sockopt.c to use MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP :
http://levsha.org.ua/sockopt.c.diff
But this patch is dirty: i think that patch break working in linux. If it is
interesting to community I shall try to realize it correctly: whit checking if
MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP is exists on configure time



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
_______________________________________________
Quagga-bugs mailing list
Quagga-bugs@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-bugs