$OpenBSD: patch-src_igmpproxy_c,v 1.2 2021/07/11 09:23:19 bket Exp $

Index: src/igmpproxy.c
--- src/igmpproxy.c.orig
+++ src/igmpproxy.c
@@ -37,13 +37,10 @@
 *   February 2005 - Johnny Egeland
 */
 
-/* getopt() and clock_getime() */
-#ifndef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200112L
-#endif
-
 #include "igmpproxy.h"
 
+#include <sys/sysctl.h>
+
 static const char Usage[] =
 "Usage: igmpproxy [-h] [-n] [-d] [-v [-v]] <configfile>\n"
 "\n"
@@ -126,6 +123,25 @@ int main( int ArgCn, char *ArgVc[] ) {
 
     openlog("igmpproxy", LOG_PID, LOG_USER);
 
+    {
+       int ipmforwarding = 0;
+       int mib[4];
+       size_t len;
+
+        /* multicast IP forwarding must be enabled */
+        mib[0] = CTL_NET;
+        mib[1] = PF_INET;
+        mib[2] = IPPROTO_IP;
+        mib[3] = IPCTL_MFORWARDING;
+        len = sizeof(ipmforwarding);
+        if (sysctl(mib, 4, &ipmforwarding, &len, NULL, 0) == -1)
+           my_log(LOG_ERR, 0, "sysctl");
+
+        if (!ipmforwarding)
+           my_log(LOG_ERR, 0, "multicast IP forwarding not enabled");
+    }
+
+
     // Write debug notice with file path...
     my_log(LOG_DEBUG, 0, "Searching for config file at '%s'" , configFilePath);
 
@@ -238,6 +254,8 @@ int igmpProxyInit(void) {
         }
 
         for ( Ix = 0; (Dp = getIfByIx(Ix)); Ix++ ) {
+            if (config_getinterface(Dp->Name) == NULL)
+               continue;
 
             if ( Dp->InAdr.s_addr && ! (Dp->Flags & IFF_LOOPBACK) ) {
                 if(Dp->state == IF_STATE_UPSTREAM) {
