is a list of changes: - Ignore interfaces that are not listed in the configuration file: fixes an abort when trying to configure interface located in a different rdomain and doesn't look to the address of interfaces outside the configuration (otherwise it would pick the wrong interface in some cases). - Improve the routing code: use a rb-tree to store groups avoiding group duplications and having to fix hand-rolled list implementations. - Fixed some warnings and improved debug messages. As discussed with ajacoutot@, ok reyk@
87 lines
2.6 KiB
Plaintext
87 lines
2.6 KiB
Plaintext
$OpenBSD: patch-igmpproxy_c,v 1.2 2016/12/23 13:44:31 rzalamena Exp $
|
|
--- igmpproxy.c.orig Thu Dec 15 19:50:24 2016
|
|
+++ igmpproxy.c Thu Dec 15 19:51:46 2016
|
|
@@ -41,8 +41,8 @@
|
|
#include "version.h"
|
|
#include "build.h"
|
|
|
|
+#include <sys/sysctl.h>
|
|
|
|
-
|
|
// Constants
|
|
static const char Version[] =
|
|
"igmpproxy, Version " VERSION ", Build" BUILD "\n"
|
|
@@ -80,7 +80,7 @@
|
|
* on commandline. The number of commandline arguments, and a
|
|
* pointer to the arguments are recieved on the line...
|
|
*/
|
|
-int main( int ArgCn, const char *ArgVc[] ) {
|
|
+int main( int ArgCn, char *ArgVc[] ) {
|
|
|
|
int debugMode = 0;
|
|
|
|
@@ -133,6 +133,24 @@
|
|
exit(1);
|
|
}
|
|
|
|
+ {
|
|
+ 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)
|
|
+ log(LOG_ERR, 0, "sysctl");
|
|
+
|
|
+ if (!ipmforwarding)
|
|
+ log(LOG_ERR, 0, "multicast IP forwarding not enabled");
|
|
+ }
|
|
+
|
|
// Write debug notice with file path...
|
|
IF_DEBUG log(LOG_DEBUG, 0, "Searching for config file at '%s'" , configFilePath);
|
|
|
|
@@ -155,17 +173,8 @@
|
|
if ( ! debugMode ) {
|
|
|
|
IF_DEBUG log( LOG_DEBUG, 0, "Starting daemon mode.");
|
|
-
|
|
- // Only daemon goes past this line...
|
|
- if (fork()) exit(0);
|
|
-
|
|
- // Detach deamon from terminal
|
|
- if ( close( 0 ) < 0 || close( 1 ) < 0 || close( 2 ) < 0
|
|
- || open( "/dev/null", 0 ) != 0 || dup2( 0, 1 ) < 0 || dup2( 0, 2 ) < 0
|
|
- || setpgrp() < 0
|
|
- ) {
|
|
+ if ( daemon(1, 0) < 0)
|
|
log( LOG_ERR, errno, "failed to detach deamon" );
|
|
- }
|
|
}
|
|
|
|
// Go to the main loop.
|
|
@@ -218,7 +227,9 @@
|
|
int vifcount = 0;
|
|
upStreamVif = -1;
|
|
|
|
- for ( Ix = 0; Dp = getIfByIx( Ix ); Ix++ ) {
|
|
+ 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) {
|
|
@@ -237,7 +248,7 @@
|
|
|
|
// If there is only one VIF, or no defined upstream VIF, we send an error.
|
|
if(vifcount < 2 || upStreamVif < 0) {
|
|
- log(LOG_ERR, 0, "There must be at least 2 Vif's where one is upstream.");
|
|
+ log(LOG_ERR, 0, "There must be at least 2 Vif's where one is upstream. (vifcount %d, upStreamVif %d)", vifcount, upStreamVif);
|
|
}
|
|
}
|
|
|