summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
Diffstat (limited to 'zebra')
-rw-r--r--zebra/ipforward_proc.c45
-rw-r--r--zebra/zserv.c16
2 files changed, 43 insertions, 18 deletions
diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c
index befa2369..4c30cf67 100644
--- a/zebra/ipforward_proc.c
+++ b/zebra/ipforward_proc.c
@@ -81,16 +81,19 @@ ipforward_on ()
fp = fopen (proc_ipv4_forwarding, "w");
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
-
- if (fp == NULL)
+ if (fp == NULL) {
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
return -1;
+ }
fprintf (fp, "1\n");
fclose (fp);
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
+
return ipforward ();
}
@@ -104,17 +107,19 @@ ipforward_off ()
fp = fopen (proc_ipv4_forwarding, "w");
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
-
-
- if (fp == NULL)
+ if (fp == NULL) {
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
return -1;
+ }
fprintf (fp, "0\n");
fclose (fp);
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
+
return ipforward ();
}
#ifdef HAVE_IPV6
@@ -149,16 +154,19 @@ ipforward_ipv6_on ()
fp = fopen (proc_ipv6_forwarding, "w");
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
-
- if (fp == NULL)
+ if (fp == NULL) {
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
return -1;
+ }
fprintf (fp, "1\n");
fclose (fp);
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
+
return ipforward_ipv6 ();
}
@@ -172,16 +180,19 @@ ipforward_ipv6_off ()
fp = fopen (proc_ipv6_forwarding, "w");
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
-
- if (fp == NULL)
+ if (fp == NULL) {
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
return -1;
+ }
fprintf (fp, "0\n");
fclose (fp);
+ if ( zserv_privs.change(ZPRIVS_LOWER) )
+ zlog_err ("Can't lower privileges, %s", strerror (errno));
+
return ipforward_ipv6 ();
}
#endif /* HAVE_IPV6 */
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 833b369d..c623151e 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -1919,9 +1919,16 @@ DEFUN (ipv6_forwarding,
{
int ret;
- ret = ipforward_ipv6_on ();
+ ret = ipforward_ipv6 ();
if (ret != 0)
{
+ vty_out (vty, "IPv6 forwarding is already on%s", VTY_NEWLINE);
+ return CMD_ERR_NOTHING_TODO;
+ }
+
+ ret = ipforward_ipv6_on ();
+ if (ret == 0)
+ {
vty_out (vty, "Can't turn on IPv6 forwarding%s", VTY_NEWLINE);
return CMD_WARNING;
}
@@ -1938,6 +1945,13 @@ DEFUN (no_ipv6_forwarding,
{
int ret;
+ ret = ipforward_ipv6 ();
+ if (ret == 0)
+ {
+ vty_out (vty, "IP forwarding is already off%s", VTY_NEWLINE);
+ return CMD_ERR_NOTHING_TODO;
+ }
+
ret = ipforward_ipv6_off ();
if (ret != 0)
{