Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pimd didn't send announcement on FreeBSD #23

Closed
ocochard opened this issue Oct 28, 2013 · 29 comments
Closed

pimd didn't send announcement on FreeBSD #23

ocochard opened this issue Oct 28, 2013 · 29 comments

Comments

@ocochard
Copy link

I've just tried to run pimd between 2 FreeBSD box (10.0-BETA2), and I've got lot's of error messages:

17:10:03.784 warning - sendto from 10.0.23.3 to 224.0.0.13:(error 22): Invalid argument
17:10:03.785 warning - Sendto to 224.0.0.1 on 10.0.34.3:(error 22): Invalid argument
17:10:03.786 warning - sendto from 10.0.34.3 to 224.0.0.13:(error 22): Invalid argument
17:10:48.527 warning - Received packet from 10.0.34.3 shorter (48 bytes) than hdr+data length (24+12264)
17:10:48.527 warning - Received packet from 10.0.23.3 shorter (48 bytes) than hdr+data length (24+12264)
17:10:48.727 warning - Received packet from 10.0.34.3 shorter (48 bytes) than hdr+data length (24+12264)
17:10:48.727 warning - Received packet from 10.0.23.3 shorter (48 bytes) than hdr+data length (24+12264)

17:11:48.877 warning - sendto from 10.0.23.3 to 224.0.0.13:(error 22): Invalid argument
17:11:48.877 warning - sendto from 10.0.34.3 to 224.0.0.13:(error 22): Invalid argument

And the second box don't received any PIM announcement from this first box.

Regards,

Olivier

@Sintezzz
Copy link

See config.mk

@troglobit
Copy link
Owner

Like @Sintezzz said, have you made sure to build for FreeBSD in config.mk? The default is to build for Linux,
and that will likely not work.

@ocochard
Copy link
Author

I've modified my config.mk by:
1). uncommented the 4 lines in "FreeBSD-3.x, FreeBSD-4.x" section: There is choice between "FreeBSD-3.x, FreeBSD-4.x" or "FreeBSD-2.x"… All these 3 versions are no more supported since about 7 years.
2). commented the 3 lines in the "Linux" section at the end of this file.

I've got no more the "sendto.. Invalid argument" warning, but PIM neighbor discovery still didn't works.

There are still this warning:
23:46:16.891 warning - received packet from 10.0.23.3 shorter (32 bytes) than hdr+data length (24+32)
23:46:16.892 warning - received packet from 10.0.23.3 shorter (32 bytes) than hdr+data length (24+32)
23:46:16.892 warning - received packet from 10.0.23.3 shorter (28 bytes) than hdr+data length (20+28)
23:46:17.487 warning - received packet from 10.0.23.2 shorter (32 bytes) than hdr+data length (24+32)

tcpdump show this trace:
[root@router]~# tcpdump -i em1 -vvv -s 0
tcpdump: listening on em1, link-type EN10MB (Ethernet), capture size 65535 bytes
23:43:47.986618 IP (tos 0x0, ttl 1, id 506, offset 0, flags [none], proto PIM (103), length 30)
10.0.23.3 > 224.0.0.13: PIMv2, length 10
Hello, cksum 0xdf93 (correct)
Hold Time Option (1), length 2, Value: 1m45s
0x0000: 0069
23:44:05.775968 IP (tos 0x0, ttl 1, id 555, offset 0, flags [none], proto PIM (103), length 30)
10.0.23.2 > 224.0.0.13: PIMv2, length 10
Hello, cksum 0xdf93 (correct)
Hold Time Option (1), length 2, Value: 1m45s
0x0000: 0069

And neighbor table still empty:

Router1:
Virtual Interface Table
Vif Local-Address Subnet Thresh Flags Neighbors
0 10.0.12.2 10.0.12/24 1 DR NO-NBR
1 10.0.23.2 10.0.23/24 1 DR NO-NBR

Router2:
Virtual Interface Table
Vif Local-Address Subnet Thresh Flags Neighbors
0 10.0.23.3 10.0.23/24 1 DR NO-NBR
1 10.0.34.3 10.0.34/24 1 DR NO-NBR

@Sintezzz
Copy link

I confirm the problem. On freebsd 9.2 does not appear PIM neighbors.
In the logs this error:
For src 192.168.90.1, iif is 0, next hop router is 10.1.5.1: NOT A PIM ROUTER
Here 192.168.90.1 - RP, and 10.1.5.1 - PIM router.
Instead of freebsd put debian with the same config everything worked.
This problem only on freebsd.

@troglobit
Copy link
Owner

Hi again, sorry for the late answer.

Could you please try with the following line not commented out in config.mk. You likely need at least the define of RAW_INPUT_IS_RAW:

DEFS         += -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET

Without it igmp.c will miscount the received data and neighbor discovery will fail. If everything works with -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW on FreeBSD I'm very keen to cleanup that mess. I've checked with the corresponding igmp.c in mrouted, that the OpenBSD people have audited, and that seems to indicate that it should work.

@ocochard
Copy link
Author

ocochard commented Jan 3, 2014

I've tried with the line not commented… but no result and the "invalid argument" warning is back:

warning - Sendto to 224.0.0.1 on 10.0.23.3:(error 22): Invalid argument
warning - Sendto to 224.0.0.1 on 10.0.34.3:(error 22): Invalid argument

@troglobit
Copy link
Owner

OK, sorry to hear, but thanks for testing it!

I'm in the process right now to install a FreeBSD 9.2 machine in Qemu. Where I'll try to sort this out.

@troglobit
Copy link
Owner

A hole slew of fixes in GIT as of 27b8a48, and it seems to work! :)

If anyone can verify, please comment out Linux section and uncomment FreeBSD 9.x section (all relevant lines) in config.mk:

# git df
diff --git a/config.mk b/config.mk
index 668efb0..b6cd416 100644
--- a/config.mk
+++ b/config.mk
@@ -59,18 +59,18 @@ DEFS       = -D__BSD_SOURCE -D_GNU_SOURCE -DPIM
 # GNU/Linux systems do not seem to ship pim.h and pim_var.h,
 # use local include/netinet
 # For uClibc based Linux systems, add -DHAVE_STRLCPY to DEFS
-INCLUDES      = -Iinclude
-DEFS         += -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET
-EXTRA_OBJS    = strlcpy.o pidfile.o
+#INCLUDES      = -Iinclude
+#DEFS         += -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET
+#EXTRA_OBJS    = strlcpy.o pidfile.o

 ## FreeBSD     -D__FreeBSD__ is defined by the OS
 ## Verified on FreeBSD-9.x, ...
 # Seems to already have ip_mroute.h and pim.h, add -Iinclude/freebsd if
 # ip_mroute.h or in.h is missing on your system and -Iinclude for pim.h
-#INCLUDES     =
-#DEFS        += -DHAVE_STRTONUM -DHAVE_STRLCPY
-#EXTRA_OBJS   = pidfile.o
-#EXTRA_LIBS   =
+INCLUDES     =
+DEFS        += -DHAVE_STRTONUM -DHAVE_STRLCPY
+EXTRA_OBJS   = pidfile.o
+EXTRA_LIBS   =

 ## NetBSD      -DNetBSD is defined by the OS
 # Seems to already have ip_mroute.h and pim.h, add -Iinclude/netbsd if

As you can see, my previous answer in this topic was unfortunately bogus.

@troglobit
Copy link
Owner

Any outstanding issues on this? I'm preparing a new release and any input would be greatly appreciated! :)

@ocochard
Copy link
Author

ocochard commented Jan 9, 2014

I've tried with the proposed config.mk: as usually it compile and start… but I still didn't see no packet output.
How exactly do you test this change ?

@troglobit
Copy link
Owner

Did you pull in the latest fixes from the master branch? Also, do you have MROUTING enabled in your kernel? I had to rebuild my FreeBSD kernel for this. (NetBSD also needed to have its kernel rebuilt with MROUTING support, only OpenBSD worked out of the box!)

I have a setup of virtual machines, four Ubuntu 12.04, one NetBSD 6.1.2, one FreeBSD 9.2 and one OpenBSD 5.4, all connected over three different bridges that I can snoop using Wireshark from my host. All routers run Quagga, with a mix of OSPF and RIP, mainly OSPF, to setup the unicast routing table that PIM-SM needs.

Admittedly, there are some problems getting my virtual networking up and running, for me it was due to bugs in the IGMP snooping handling in the Linux bridge code on my host system. I've documented bits of it on my home page http://troglobit.com/multicast-howto.html

@ocochard
Copy link
Author

ocochard commented Jan 9, 2014

I've tried the release afe15a9 on FreeBSD 10.0-RC5 and here is my problem:

  • The daemon correctly send mcast IGMP and PIM message.
  • But it didn't correctly subscribe to the 224.0.0.13 mcast group to the OS: the NIC multicast filter is not updated, then only mcast packet sent to 224.0.0.1 are received, but PIM mcast packet sent to 224.0.0.13 are not received by the OS.
    I've seen this by using tcpdump in non-promiscious mode on the FreeBSD: PIM packets from neighbor are not seen (but if you run tcpdump in promiscious mode you see the PIM packets).

@troglobit
Copy link
Owner

Aha, thanks for the update!

Oddly enough it seems to work on my 9.2 setup. :-(

Do you see any "Cannot join group ..." in your logs?

root@fbsd:~/pimd # ifconfig 
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
    ether 52:54:00:65:61:39
    inet 192.168.122.148 netmask 0xffffff00 broadcast 192.168.122.255
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active

Could it be something as simple as the interface flags not being set with MULTICAST? I know some bad drivers on Linux have problems with that ... other than that, I cannot find anything else than grasping for straws ... like this one https://forums.freebsd.org/viewtopic.php?&t=42583 ...

@troglobit
Copy link
Owner

My FreeBSD-fu is weak, but it seems the Linux /proc/net/igmp stats can be seen with the ifmcstat tool (which looks awesome btw!). On my system I get the following:

root@fbsd:~/pimd # ./pimd 
root@fbsd:~/pimd # ifmcstat
em0:
    inet 192.168.122.148
    igmpv2
        group 224.0.0.22 mode exclude
            mcast-macaddr 01:00:5e:00:00:16
        group 224.0.0.2 mode exclude
            mcast-macaddr 01:00:5e:00:00:02
        group 224.0.0.13 mode exclude
            mcast-macaddr 01:00:5e:00:00:0d
        group 224.0.0.1 mode exclude
            mcast-macaddr 01:00:5e:00:00:01
re0:
    inet 172.16.12.3
    igmpv2
        group 224.0.0.22 mode exclude
            mcast-macaddr 01:00:5e:00:00:16
        group 224.0.0.2 mode exclude
            mcast-macaddr 01:00:5e:00:00:02
        group 224.0.0.13 mode exclude
            mcast-macaddr 01:00:5e:00:00:0d
        group 224.0.0.6 mode exclude
            mcast-macaddr 01:00:5e:00:00:06
        group 224.0.0.5 mode exclude
            mcast-macaddr 01:00:5e:00:00:05
        group 224.0.0.1 mode exclude
            mcast-macaddr 01:00:5e:00:00:01
lo0:
    inet 127.0.0.1
    igmpv3 rv 2 qi 125 qri 10 uri 3
        group 224.0.0.1 mode exclude
    inet6 fe80::1%lo0
    mldv2 flags=2<USEALLOW> rv 2 qi 125 qri 10 uri 3
        group ff01::1%lo0 mode exclude
        group ff02::2:3a7d:85b7%lo0 mode exclude
        group ff02::2:ff3a:7d85%lo0 mode exclude
        group ff02::1%lo0 mode exclude
        group ff02::1:ff00:1%lo0 mode exclude

So it successfully changes to mode exclude for 224.0.0.13 for me. The kernel is GENERIC + "options MROUTING" ...

@ocochard
Copy link
Author

Ok, I've tried to document the lab I'm working on here:
http://bsdrp.net/documentation/examples/multicast_with_pim-sm

=> pimd correctly subscribe to 224.0.0.13, I did a mistake.
Then all routers should receive PIM hello message (and BSR announce), but they don't take care of them.

By the way, I've write a FreeBSD port of pimd, you can download it from here:
cd /usr/ports
fetch -o ports.pimd.shar "https://sourceforge.net/p/bsdrp/code/HEAD/tree/trunk/BSDRP/patches/ports.pimd.shar?format=raw"
sh ports.pimd.shar
cd net/pimd
make install

Once I will reach it to use it I will push the port in the official FreeBSD port tree.

Regards,

@troglobit
Copy link
Owner

Great to hear, looking forward to having pimd stable in ports! :)

Now, that warning you still see ... that's likely the root cause of this whole mess.
Make sure you do NOT have RAW_INPUT_IS_RAW defined. FreeBSD should
not have this.

(I'm changing the whole config.mk mess to fix this, will try to make it all auto-detect the OS instead ...)

@ocochard
Copy link
Author

Yes I've commented all lines in the Linux section (then all the RAW), the patch file included in the port have this form:

root@bsdrp:/usr/ports/net/pimd # cat files/patch-config.mk
--- config.mk.orig 2014-01-06 09:40:16.000000000 +0100
+++ config.mk 2014-01-10 10:15:18.688897140 +0100
@@ -59,9 +59,9 @@

GNU/Linux systems do not seem to ship pim.h and pim_var.h,

use local include/netinet

For uClibc based Linux systems, add -DHAVE_STRLCPY to DEFS

-INCLUDES = -Iinclude
-DEFS += -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET
-EXTRA_OBJS = strlcpy.o pidfile.o
+#INCLUDES = -Iinclude
+#DEFS += -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET
+#EXTRA_OBJS = strlcpy.o pidfile.o

FreeBSD -D__FreeBSD__ is defined by the OS

Verified on FreeBSD-9.2, ...

@@ -71,10 +71,10 @@

For older versions, add the following to INCLUDES below:

-Iinclude/freebsd if ip_mroute.h or in.h is missing, and

-Iinclude if pim.h is missing

-#INCLUDES =
-#DEFS += -DHAVE_STRTONUM -DHAVE_STRLCPY
-#EXTRA_OBJS = pidfile.o
-#EXTRA_LIBS =
+INCLUDES =
+DEFS += -DHAVE_STRTONUM -DHAVE_STRLCPY
+EXTRA_OBJS = pidfile.o
+EXTRA_LIBS =

NetBSD -DNetBSD is defined by the OS

Verified on NetBSD 6.1.2, ...

@troglobit
Copy link
Owner

That's so utterly bizarre ... I really don't get those warnings, can't really figure out what they might be caused by either.

Well, I've pushed the new configure script, so you won't have to edit/patch config.mk anymore. If you could try:

git checkout config.mk
git pull
./configure
make clean all

... and then try again, I would be most grateful. Even though I've run out of ideas on how to fix your problem :-/

@ocochard
Copy link
Author

Your new configure script works fine !
I believe the multicast problem came from FreeBSD 10.0 because I confirm that it run fine on FreeBSD 9.2 too.
I've updated the FreeBSD port with your latest release and ask for help on the FreeBSD mailing-list here:
http://lists.freebsd.org/pipermail/freebsd-net/2014-January/037497.html

@troglobit
Copy link
Owner

That's both great and slightly troubling news at the same time. Hope you get some attention on the mailing list! I'm not subscribed, but don't hesitate sending devs here, or to my gmail address directly. Thanks!

@ocochard
Copy link
Author

API was changed in 10.0, full explantation here:
http://lists.freebsd.org/pipermail/freebsd-net/2014-January/037512.html

I've try a patch without success (no more warning message but still no PIM neighbor seen): http://pastebin.com/mX4xaWf5

I've only patched igmp.c, peraps we should patch pim.c too ?

@troglobit
Copy link
Owner

Uh, that's a fine mess they've created for themselves there. Seems FreeBSD 11 will be a lot more like Linux's reallay RAW sockets.

I'm afraid that you might need to patch every place where ip->ip_len is used :-(

I'd like to help out, which I will as soon as I get the time and have installed the fresh new FreeBSD 10, but right now I'm unfortunately busy with both work and another pimd issue (fragmentation of >MTU sized multicast frames). The pimd 2.2.0 release is postponed until both that issue and this FreeBSD issue is fixed.

@ocochard
Copy link
Author

Don't spend your time on FreeBSD 10.0: Multicast PIM is broken on this release. Notice that releases X.0 are known for having lot's of regression.

@troglobit
Copy link
Owner

Ah, thanks for the heads up! That is very unfortunate for FreeBSD, but I'll try to document it somewhere at least.

@ocochard
Copy link
Author

ocochard commented Sep 1, 2014

Just for the record: We've converted the FreeBSD RAW socket to be really RAW (like on Linux): http://svnweb.freebsd.org/base?view=revision&revision=270929
Will be included on FreeBSD 11.

@troglobit
Copy link
Owner

Great stuff, thanks @ocochard for the notification! I hope to get some time working on pimd and FreeBSD soon.

@troglobit
Copy link
Owner

@ocochard I patched up my FreeBSD 10 kernel, and now I've got pimd working! Will push my changes soon :)

Also, after reading the kernel sources I understand more what it is that FreeBSD 10 does differently, so I'd like to try and support it too. Do you know what the preferred way of handling these sort of API differences on *BSD are? Should I use "#if __FreeBSD_version < 1100030" for all FreeBSD 10 and older, or do I need to do some more magic, e.g. for FreeBSD 9 and older?

... or maybe this is all documented somewhere and I should RTFM? ;)

@ocochard
Copy link
Author

yes, the usage of "#if __FreeBSD_version < 1100030" is the correct way.
There are example of patches here: https://wiki.freebsd.org/SOCK_RAW

troglobit added a commit that referenced this issue Sep 23, 2014
See issue #23 and https://wiki.freebsd.org/SOCK_RAW for details.  Thanks
to Olivier Cochard-Labbé for all the sparring help on this and his work
on FreeBSD!

Signed-off-by: Joachim Nilsson <[email protected]>
@troglobit
Copy link
Owner

There, it should be fixed now. Thank you so much for the help, @ocochard :-)

pimd should now work on both older FreeBSD and the new raw socket code in the upcoming FreeBSD 11. Wasn't too hard after all.

If only I could wrap my head around the fragmentation of register messages, then we could get a release out ...

troglobit added a commit to troglobit/mrouted that referenced this issue Oct 28, 2014
This is a port of the troglobit/pimd#23 patch that was brought
to my attention by Olivier Cochard-Labbé.  See the FreeBSD help
at https://wiki.freebsd.org/SOCK_RAW for details.

Signed-off-by: Joachim Nilsson <[email protected]>
troglobit added a commit that referenced this issue Dec 31, 2015
This is a speculative, but very probable, fix for the FreeBSD regression
reported in issue #57.  In 28bbf4e two new checks for BSD `SOCK_RAW` was
added, which seems didn't apply at all.

Turns out PIM register messages, both send & receive, are in fact passed
as truly RAW.  At least on FreeBSD.  This fix only reverts checks added
to IGMP_PROTO sockets.

Signed-off-by: Joachim Nilsson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants