Bug 208652

Summary: [PATCH] net/mdns-repeater: bind to proper interface; strerror
Product: Ports & Packages Reporter: Johan Ström <johan>
Component: Individual Port(s)Assignee: Emanuel Haupt <ehaupt>
Status: Closed FIXED    
Severity: Affects Only Me Keywords: patch
Priority: --- Flags: bugzilla: maintainer-feedback? (ehaupt)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to fix interface binding & error messages on FreeBSD. johan: maintainer-approval?

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 freebsd_triage 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 freebsd_triage 2016-04-10 23:14:42 UTC
Thank you very much for this fine patch. I've just committed it.