summaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/fwd/src/fwd.c18
-rw-r--r--contrib/fwd/src/fwd_config.c8
-rw-r--r--contrib/fwd/src/fwd_rules.c35
3 files changed, 24 insertions, 37 deletions
diff --git a/contrib/fwd/src/fwd.c b/contrib/fwd/src/fwd.c
index 0b25cb038..662524e35 100644
--- a/contrib/fwd/src/fwd.c
+++ b/contrib/fwd/src/fwd.c
@@ -106,19 +106,31 @@ static int fwd_server_main(int argc, const char *argv[])
if( !fwd_empty_cidr(addr_new) && fwd_empty_cidr(addr_old) )
{
- printf("IFUP[%s]\n", net->ifname);
+ fwd_log_info(
+ "Interface %s brought up - adding rules",
+ net->ifname
+ );
+
fwd_update_cidr(addr_old, addr_new);
fwd_ipt_addif(h, net->name);
}
else if( fwd_empty_cidr(addr_new) && !fwd_empty_cidr(addr_old) )
{
- printf("IFDOWN[%s]\n", net->ifname);
+ fwd_log_info(
+ "Interface %s went down - removing rules",
+ net->ifname
+ );
+
fwd_update_cidr(addr_old, NULL);
fwd_ipt_delif(h, net->name);
}
else if( ! fwd_equal_cidr(addr_old, addr_new) )
{
- printf("IFCHANGE[%s]\n", net->ifname);
+ fwd_log_info(
+ "Interface %s changed IP - rebuilding rules",
+ net->ifname
+ );
+
fwd_update_cidr(addr_old, addr_new);
fwd_ipt_chgif(h, net->name);
}
diff --git a/contrib/fwd/src/fwd_config.c b/contrib/fwd/src/fwd_config.c
index def36d139..320e9ffca 100644
--- a/contrib/fwd/src/fwd_config.c
+++ b/contrib/fwd/src/fwd_config.c
@@ -25,11 +25,9 @@
#include "ucix.h"
-#define fwd_read_error(...) do { \
- fprintf(stderr, "ERROR: "); \
- fprintf(stderr, __VA_ARGS__); \
- fprintf(stderr, "\n"); \
- return; \
+#define fwd_read_error(...) do { \
+ fwd_log_err(__VA_ARGS__); \
+ return; \
} while(0)
diff --git a/contrib/fwd/src/fwd_rules.c b/contrib/fwd/src/fwd_rules.c
index 3e7314f36..b960e62fd 100644
--- a/contrib/fwd/src/fwd_rules.c
+++ b/contrib/fwd/src/fwd_rules.c
@@ -496,12 +496,13 @@ void fwd_ipt_build_ruleset(struct fwd_handle *h)
switch(e->type)
{
case FWD_S_DEFAULTS:
- printf("\n## DEFAULTS\n");
+ fwd_log_info("Loading defaults");
fwd_ipt_defaults_create(e);
break;
case FWD_S_INCLUDE:
- printf("\n## INCLUDE %s\n", e->section.include.path);
+ fwd_log_info("Loading include: %s",
+ e->section.include.path);
break;
case FWD_S_ZONE:
@@ -573,13 +574,12 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
return;
- printf("\n\n#\n# addif(%s)\n#\n", net);
+ fwd_log_info("Adding network %s (interface %s)",
+ n->name, n->ifname);
/* Build masquerading rule */
if( z->masq )
{
- printf("\n# Net %s (%s) - masq\n", n->name, n->ifname);
-
if( (x = fwd_xt_init_rule(h_nat)) != NULL )
{
fwd_xt_parse_out(x, n, 0); /* -o ... */
@@ -592,8 +592,6 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
/* Build MSS fix rule */
if( z->mtu_fix )
{
- printf("\n# Net %s (%s) - mtu_fix\n", n->name, n->ifname);
-
if( (x = fwd_xt_init_rule(h_filter)) != NULL )
{
p.type = FWD_PR_TCP;
@@ -621,11 +619,6 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
{
if( (a2 = n2->addr) != NULL )
{
- printf("\n# Net %s (%s) - intra-zone-forwarding"
- " Z:%s N:%s I:%s -> Z:%s N:%s I:%s\n",
- n->name, n->ifname, z->name, n->name, n->ifname,
- z->name, n2->name, n2->ifname);
-
if( (x = fwd_xt_init_rule(h_filter)) != NULL )
{
fwd_xt_parse_in(x, n, 0); /* -i ... */
@@ -642,11 +635,6 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
{
for( n2 = f->dest->networks; n2; n2 = n2->next )
{
- printf("\n# Net %s (%s) - inter-zone-forwarding"
- " Z:%s N:%s I:%s -> Z:%s N:%s I:%s\n",
- n->name, n->ifname, z->name, n->name, n->ifname,
- f->dest->name, n2->name, n2->ifname);
-
/* Build forwarding rule */
if( (x = fwd_xt_init_rule(h_filter)) != NULL )
{
@@ -662,9 +650,6 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
/* Build DNAT rules */
for( e = z->redirects; e && (r = &e->section.redirect); e = e->next )
{
- printf("\n# Net %s (%s) - redirect Z:%s N:%s I:%s\n",
- n->name, n->ifname, z->name, n->name, n->ifname);
-
/* DNAT */
if( (x = fwd_xt_init_rule(h_nat)) != NULL )
{
@@ -720,11 +705,6 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
{
for( n2 = c->dest->networks; n2; n2 = n2->next )
{
- printf("\n# Net %s (%s) - rule+dest"
- " Z:%s N:%s I:%s -> Z:%s N:%s I:%s\n",
- n->name, n->ifname, z->name, n->name, n->ifname,
- f->dest->name, n2->name, n2->ifname);
-
if( (x = fwd_xt_init_rule(h_filter)) != NULL )
{
fwd_xt_parse_in(x, n, 0); /* -i ... */
@@ -746,9 +726,6 @@ void fwd_ipt_addif(struct fwd_handle *h, const char *net)
/* No destination specified, treat it as input rule */
else
{
- printf("\n# Net %s (%s) - rule Z:%s N:%s I:%s\n",
- n->name, n->ifname, z->name, n->name, n->ifname);
-
if( (x = fwd_xt_init_rule(h_filter)) != NULL )
{
fwd_xt_parse_in(x, n, 0); /* -i ... */
@@ -835,7 +812,7 @@ void fwd_ipt_delif(struct fwd_handle *h, const char *net)
fwd_fatal("Unable to obtain libiptc handle");
- printf("\n\n#\n# delif(%s)\n#\n", net);
+ fwd_log_info("Removing network %s", net);
/* delete network related rules */
fwd_ipt_delif_table(h_nat, net);