troglobit / smcroute

Static multicast routing for UNIX
https://troglobit.com/projects/smcroute/
GNU General Public License v2.0
242 stars 62 forks source link

Parse error in conf file #175

Closed alexeys85 closed 2 years ago

alexeys85 commented 2 years ago

Hi!

I use pretty simple config: phyint eth1 enable ttl-threshold 1 mrdisc phyint net1 enable ttl-threshold 2 phyint net2 enable ttl-threshold 2 phyint net3 enable ttl-threshold 2 phyint net4 enable ttl-threshold 2 mgroup from eth1 group 225.1.2.3 source 192.168.1.42 mroute from eth1 group 225.1.2.3 source 192.168.1.42 to net1

And it works just fine, until I pass -N flag to smcroute. In that case it also works fine except there is a message in the log: smcroute[2789]: Parse error in /etc/smcroute.conf. Both cases observed in 2.5.3 and 2.5.4 versions. Didn't check in previous versions.

troglobit commented 2 years ago

Well, does all these interfaces exist on the system? I've set up something similar with your config, different interfaec names only, and that works fine as long as the interfaces exist.

alexeys85 commented 2 years ago

Yes, they do. As I said there is only one difference - existing '-N' flag which causing this log message to appear. This log is with -N flag: Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface lo, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface eth0, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface eth1, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface ifb0, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface teql0, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface macv0, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface tunl0, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface net1, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface net2, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface net3, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found new interface net4, adding ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found lo, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Removing multicast VIFs for lo Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth1, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found eth1, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found macv0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Found macv0, updating ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: NOFILE: current 1024 max 0 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: NOFILE: set new current 4096 max 0 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Binding IPC socket to /var/run/smcroute.sock Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 1: phyint eth1 enable ttl-threshold 1 mrdisc Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Creating/updating multicast VIF for eth1 TTL 1 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Map iface eth1 => VIF 0 ifindex 3 flags 0x0008 TTL threshold 1 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Sending mrdisc announcement on eth1 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 2: Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 3: phyint net1 enable ttl-threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Creating/updating multicast VIF for net1 TTL 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Map iface net1 => VIF 1 ifindex 8 flags 0x0008 TTL threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 4: phyint net2 enable ttl-threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Creating/updating multicast VIF for net2 TTL 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Map iface net2 => VIF 2 ifindex 9 flags 0x0008 TTL threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 5: phyint net3 enable ttl-threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Creating/updating multicast VIF for net3 TTL 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Map iface net3 => VIF 3 ifindex 10 flags 0x0008 TTL threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 6: phyint net4 enable ttl-threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Creating/updating multicast VIF for net4 TTL 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Map iface net4 => VIF 4 ifindex 11 flags 0x0008 TTL threshold 2 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 7: Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 8: mgroup from eth1 group 225.1.2.3 source 192.168.1.42 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Group socket 10 count 1 of MAX 20 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Join group (192.168.1.42,225.1.2.3) on ifindex 3 and socket 10 ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 9: mroute from eth1 group 225.1.2.3 source 192.168.1.42 to net1 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 9: mroute: checking for input iface eth1 ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 9: mroute: input iface eth1 has vif 0 Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: /etc/smcroute.conf line 9: mroute: checking for net1 ... Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: mroute: adding route from eth1 (192.168.1.42/32,225.1.2.3/32) Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Add 192.168.1.42 -> 225.1.2.3 from VIF 0 Sat Jan 1 05:18:08 2000 daemon.warn smcroute[2788]: Parse error in /etc/smcroute.conf Sat Jan 1 05:18:08 2000 daemon.debug smcroute[2788]: Creating PID file /var/run/smcroute.pid Sat Jan 1 05:18:08 2000 daemon.notice smcroute[2788]: Ready, waiting for client request or kernel event. Lines 2 and 7 are white lines. As you see it parsed all lines from file and started to work fine, but with error message.

troglobit commented 2 years ago

Hmm, could you show me the complete command line for starting smcrouted? It's a bit fishy that the daemon name is smcroute instead of smcrouted, unless you're using -i smcroute, or maybe you're using the old/deprecated smcroute wrapper script? Because I simply cannot reproduce your issue with the latest release ...

troglobit commented 2 years ago

Also, could you dump the output of ip link and ip addr? Just to verify that the correct flags and IP addresses are set.

alexeys85 commented 2 years ago

By the way, its OpenWrt 21.01

root@RTS1:~# ps | grep smcroute
 2789 root       840 S    /usr/sbin/smcrouted -n -N -f /etc/smcroute.conf -l debug
 3032 root      1148 S    grep smcroute

I tried to debug smcroute code and inserted a smclog statement here: https://github.com/troglobit/smcroute/blob/e22f63d652495f690870a1d94aca97355b25390a/src/conf.c#L468-L471 and the value of rc var was -4. Then I remove mrdisc from smcroute.conf and rc became -5. TLDR; I found that this code decrements rc: https://github.com/troglobit/smcroute/blob/e22f63d652495f690870a1d94aca97355b25390a/src/mrdisc.c#L328-L329 because I build smcroute with mrdisc support.

troglobit commented 2 years ago

Thanks, reproduced now! :-)

Just pushed a fix, the mrdisc_deregister() function should not fail for never registered interfaces.

troglobit commented 2 years ago

I'll prepare a new release in a couple of days, and hopefully get it out the door during the weekend.

Thank you for reporting and helping debug this! <3

alexeys85 commented 2 years ago

Thanks, works now!

troglobit commented 2 years ago

Great :)

troglobit commented 2 years ago

Release available at https://github.com/troglobit/smcroute/releases/tag/2.5.5