|
|
4aca6e |
From 88997b4cd8480bcbcb3b0470020968a944495233 Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
4aca6e |
Date: Tue, 28 Feb 2017 16:10:15 +0100
|
|
|
049c96 |
Subject: [PATCH] fix ip -force -batch to continue on errors
|
|
|
049c96 |
|
|
|
4aca6e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
|
|
|
049c96 |
Upstream Status: iproute2.git commit 42ecedd4bae53
|
|
|
4aca6e |
Conflicts: Previously backported changes to rtnl_talk() signature.
|
|
|
049c96 |
|
|
|
049c96 |
commit 42ecedd4bae534fc688194a795eb4548c6530cda
|
|
|
049c96 |
Author: Roopa Prabhu <roopa@cumulusnetworks.com>
|
|
|
049c96 |
Date: Tue Mar 17 19:26:32 2015 -0700
|
|
|
049c96 |
|
|
|
049c96 |
fix ip -force -batch to continue on errors
|
|
|
049c96 |
|
|
|
049c96 |
This patch replaces exits with returns in several
|
|
|
049c96 |
iproute2 commands. This fixes `ip -batch -force`
|
|
|
049c96 |
to not exit but continue on errors.
|
|
|
049c96 |
|
|
|
049c96 |
$cat c.txt
|
|
|
049c96 |
route del 1.2.3.0/24 dev eth0
|
|
|
049c96 |
route del 1.2.4.0/24 dev eth0
|
|
|
049c96 |
route del 1.2.5.0/24 dev eth0
|
|
|
049c96 |
route add 1.2.3.0/24 dev eth0
|
|
|
049c96 |
|
|
|
049c96 |
$ip -force -batch c.txt
|
|
|
049c96 |
RTNETLINK answers: No such process
|
|
|
049c96 |
Command failed c.txt:2
|
|
|
049c96 |
RTNETLINK answers: No such process
|
|
|
049c96 |
Command failed c.txt:3
|
|
|
049c96 |
|
|
|
049c96 |
Reported-by: Sven-Haegar Koch <haegar@sdinet.de>
|
|
|
049c96 |
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
|
|
|
049c96 |
---
|
|
|
049c96 |
bridge/fdb.c | 6 +++---
|
|
|
4aca6e |
bridge/link.c | 24 ++++++++++++------------
|
|
|
049c96 |
bridge/mdb.c | 8 ++++----
|
|
|
049c96 |
bridge/vlan.c | 4 ++--
|
|
|
049c96 |
ip/iproute.c | 2 +-
|
|
|
4aca6e |
5 files changed, 22 insertions(+), 22 deletions(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/bridge/fdb.c b/bridge/fdb.c
|
|
|
4aca6e |
index e411932..3020633 100644
|
|
|
049c96 |
--- a/bridge/fdb.c
|
|
|
049c96 |
+++ b/bridge/fdb.c
|
|
|
4aca6e |
@@ -322,7 +322,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
049c96 |
|
|
|
049c96 |
if (d == NULL || addr == NULL) {
|
|
|
049c96 |
fprintf(stderr, "Device and address are required arguments.\n");
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
/* Assume self */
|
|
|
4aca6e |
@@ -337,7 +337,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
049c96 |
abuf, abuf+1, abuf+2,
|
|
|
049c96 |
abuf+3, abuf+4, abuf+5) != 6) {
|
|
|
049c96 |
fprintf(stderr, "Invalid mac address %s\n", addr);
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
addattr_l(&req.n, sizeof(req), NDA_LLADDR, abuf, ETH_ALEN);
|
|
|
4aca6e |
@@ -365,7 +365,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
4aca6e |
if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
|
|
|
049c96 |
- exit(2);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
diff --git a/bridge/link.c b/bridge/link.c
|
|
|
4aca6e |
index 69c0bfb..a9b1262 100644
|
|
|
049c96 |
--- a/bridge/link.c
|
|
|
049c96 |
+++ b/bridge/link.c
|
|
|
4aca6e |
@@ -284,31 +284,31 @@ static int brlink_modify(int argc, char **argv)
|
|
|
049c96 |
} else if (strcmp(*argv, "guard") == 0) {
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
if (!on_off("guard", &bpdu_guard, *argv))
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
} else if (strcmp(*argv, "hairpin") == 0) {
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
if (!on_off("hairping", &hairpin, *argv))
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
} else if (strcmp(*argv, "fastleave") == 0) {
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
if (!on_off("fastleave", &fast_leave, *argv))
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
} else if (strcmp(*argv, "root_block") == 0) {
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
if (!on_off("root_block", &root_block, *argv))
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
4aca6e |
} else if (strcmp(*argv, "learning") == 0) {
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
if (!on_off("learning", &learning, *argv))
|
|
|
4aca6e |
- exit(-1);
|
|
|
4aca6e |
+ return -1;
|
|
|
4aca6e |
} else if (strcmp(*argv, "learning_sync") == 0) {
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
if (!on_off("learning_sync", &learning_sync, *argv))
|
|
|
4aca6e |
- exit(-1);
|
|
|
4aca6e |
+ return -1;
|
|
|
4aca6e |
} else if (strcmp(*argv, "flood") == 0) {
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
if (!on_off("flood", &flood, *argv))
|
|
|
4aca6e |
- exit(-1);
|
|
|
4aca6e |
+ return -1;
|
|
|
049c96 |
} else if (strcmp(*argv, "cost") == 0) {
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
cost = atoi(*argv);
|
|
|
4aca6e |
@@ -327,7 +327,7 @@ static int brlink_modify(int argc, char **argv)
|
|
|
049c96 |
if (state == nstates) {
|
|
|
049c96 |
fprintf(stderr,
|
|
|
049c96 |
"Error: invalid STP port state\n");
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
}
|
|
|
049c96 |
} else if (strcmp(*argv, "hwmode") == 0) {
|
|
|
4aca6e |
@@ -341,7 +341,7 @@ static int brlink_modify(int argc, char **argv)
|
|
|
049c96 |
fprintf(stderr,
|
|
|
049c96 |
"Mode argument must be \"vepa\" or "
|
|
|
049c96 |
"\"veb\".\n");
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
4aca6e |
} else if (strcmp(*argv, "self") == 0) {
|
|
|
4aca6e |
flags |= BRIDGE_FLAGS_SELF;
|
|
|
4aca6e |
@@ -354,14 +354,14 @@ static int brlink_modify(int argc, char **argv)
|
|
|
049c96 |
}
|
|
|
049c96 |
if (d == NULL) {
|
|
|
049c96 |
fprintf(stderr, "Device is a required argument.\n");
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
|
|
|
049c96 |
req.ifm.ifi_index = ll_name_to_index(d);
|
|
|
049c96 |
if (req.ifm.ifi_index == 0) {
|
|
|
049c96 |
fprintf(stderr, "Cannot find bridge device \"%s\"\n", d);
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
/* Nested PROTINFO attribute. Contains: port flags, cost, priority and
|
|
|
4aca6e |
@@ -416,7 +416,7 @@ static int brlink_modify(int argc, char **argv)
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
4aca6e |
if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
|
|
|
049c96 |
- exit(2);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
diff --git a/bridge/mdb.c b/bridge/mdb.c
|
|
|
4aca6e |
index 837fa5d..9a8ed54 100644
|
|
|
049c96 |
--- a/bridge/mdb.c
|
|
|
049c96 |
+++ b/bridge/mdb.c
|
|
|
049c96 |
@@ -145,12 +145,12 @@ static int mdb_show(int argc, char **argv)
|
|
|
049c96 |
|
|
|
049c96 |
if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETMDB) < 0) {
|
|
|
049c96 |
perror("Cannot send dump request");
|
|
|
049c96 |
- exit(1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
if (rtnl_dump_filter(&rth, print_mdb, stdout) < 0) {
|
|
|
049c96 |
fprintf(stderr, "Dump terminated\n");
|
|
|
049c96 |
- exit(1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
@@ -198,7 +198,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
049c96 |
|
|
|
049c96 |
if (d == NULL || grp == NULL || p == NULL) {
|
|
|
049c96 |
fprintf(stderr, "Device, group address and port name are required arguments.\n");
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
req.bpm.ifindex = ll_name_to_index(d);
|
|
|
049c96 |
@@ -225,7 +225,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
049c96 |
addattr_l(&req.n, sizeof(req), MDBA_SET_ENTRY, &entry, sizeof(entry));
|
|
|
049c96 |
|
|
|
4aca6e |
if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
|
|
|
049c96 |
- exit(2);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
diff --git a/bridge/vlan.c b/bridge/vlan.c
|
|
|
4aca6e |
index 0fb479c..ac2f523 100644
|
|
|
049c96 |
--- a/bridge/vlan.c
|
|
|
049c96 |
+++ b/bridge/vlan.c
|
|
|
4aca6e |
@@ -80,7 +80,7 @@ static int vlan_modify(int cmd, int argc, char **argv)
|
|
|
049c96 |
|
|
|
049c96 |
if (d == NULL || vid == -1) {
|
|
|
049c96 |
fprintf(stderr, "Device and VLAN ID are required arguments.\n");
|
|
|
049c96 |
- exit(-1);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
req.ifm.ifi_index = ll_name_to_index(d);
|
|
|
4aca6e |
@@ -132,7 +132,7 @@ static int vlan_modify(int cmd, int argc, char **argv)
|
|
|
049c96 |
addattr_nest_end(&req.n, afspec);
|
|
|
049c96 |
|
|
|
4aca6e |
if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
|
|
|
049c96 |
- exit(2);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
diff --git a/ip/iproute.c b/ip/iproute.c
|
|
|
4aca6e |
index 8a706ea..9dcfd19 100644
|
|
|
049c96 |
--- a/ip/iproute.c
|
|
|
049c96 |
+++ b/ip/iproute.c
|
|
|
4aca6e |
@@ -1112,7 +1112,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
|
|
|
049c96 |
req.r.rtm_family = AF_INET;
|
|
|
049c96 |
|
|
|
4aca6e |
if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
|
|
|
049c96 |
- exit(2);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|