Bug 208652 - [PATCH] net/mdns-repeater: bind to proper interface; strerror
Summary: [PATCH] net/mdns-repeater: bind to proper interface; strerror
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Emanuel Haupt
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-04-09 11:57 UTC by Johan Ström
Modified: 2016-04-10 23:14 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (ehaupt)


Attachments
Patch to fix interface binding & error messages on FreeBSD. (5.22 KB, patch)
2016-04-09 11:57 UTC, Johan Ström
johan: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Ström 2016-04-09 11:57:58 UTC
Created attachment 169123 [details]
Patch to fix interface binding & error messages on FreeBSD.

The net/mdns-repeater port is supposed to read one mDNS multicast packet from one interface, and forward it to one or more interfaces.

On FreeBSD it does not properly bind each sending socket to their corresponding interface, instead it just sends to multi-cast IP 244.0.0.251, which is emitted on the interface found via the default route (at least that was the case here). In my case this was my internet interface, resulting in all packets getting blocked by my firewall (and not sent at all to the proper interfaces).
Not sure if this have ever worked on a multi-homed machine, but perhaps all the users have wanted it to forward to the interface with the default route, and assumed it was fine.

The existing code solves this with the Linux-specific SO_BINDTODEVICE opt, if it exists. It doesn't on FreeBSD.
The attached patch fixes this by using the IP_MULTICAST_IF socket option instead.

The patch also replaces the use of GNU-specific %m formatter (expands to strerror(errno)). While this works on FreeBSD syslog(3), it does not work on FreeBSD printf(3).

Patch built with make makepatch.
Comment 1 commit-hook freebsd_committer 2016-04-10 23:11:31 UTC
A commit references this bug:

Author: ehaupt
Date: Sun Apr 10 23:10:50 UTC 2016
New revision: 412989
URL: https://svnweb.freebsd.org/changeset/ports/412989

Log:
  Fix interface binding & error messages.

  PR:		208652
  Submitted by:	johan

Changes:
  head/net/mdns-repeater/Makefile
  head/net/mdns-repeater/files/patch-mdns-repeater.c
Comment 2 Emanuel Haupt freebsd_committer 2016-04-10 23:14:42 UTC
Thank you very much for this fine patch. I've just committed it.