linma / rpms / iproute

Forked from rpms/iproute 4 years ago
Clone

Blame SOURCES/0023-fix-ip-force-batch-to-continue-on-errors.patch

049c96
From 03f8f5811ebc0f8fac1c3ccb76c14007d250bd38 Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Thu, 18 Feb 2016 14:05:04 +0100
049c96
Subject: [PATCH] fix ip -force -batch to continue on errors
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1288042
049c96
Upstream Status: iproute2.git commit 42ecedd4bae53
049c96
Conflicts: Context changed due to missing other commits adding policy
049c96
           flags (e.g. learning_sync).
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 +++---
049c96
 bridge/link.c | 18 +++++++++---------
049c96
 bridge/mdb.c  |  8 ++++----
049c96
 bridge/vlan.c |  4 ++--
049c96
 ip/iproute.c  |  2 +-
049c96
 5 files changed, 19 insertions(+), 19 deletions(-)
049c96
049c96
diff --git a/bridge/fdb.c b/bridge/fdb.c
049c96
index 513b3f9..b8138cb 100644
049c96
--- a/bridge/fdb.c
049c96
+++ b/bridge/fdb.c
049c96
@@ -287,7 +287,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 */
049c96
@@ -302,7 +302,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);
049c96
@@ -330,7 +330,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
049c96
 	}
049c96
 
049c96
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
049c96
-		exit(2);
049c96
+		return -1;
049c96
 
049c96
 	return 0;
049c96
 }
049c96
diff --git a/bridge/link.c b/bridge/link.c
049c96
index 48be938..c5e7ae5 100644
049c96
--- a/bridge/link.c
049c96
+++ b/bridge/link.c
049c96
@@ -268,19 +268,19 @@ 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;
049c96
 		} else if (strcmp(*argv, "cost") == 0) {
049c96
 			NEXT_ARG();
049c96
 			cost = atoi(*argv);
049c96
@@ -299,7 +299,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) {
049c96
@@ -313,7 +313,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
 			}
049c96
 		} else {
049c96
 			usage();
049c96
@@ -322,14 +322,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
049c96
@@ -377,7 +377,7 @@ static int brlink_modify(int argc, char **argv)
049c96
 	}
049c96
 
049c96
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
049c96
-		exit(2);
049c96
+		return -1;
049c96
 
049c96
 	return 0;
049c96
 }
049c96
diff --git a/bridge/mdb.c b/bridge/mdb.c
049c96
index 81d479b..ab3a792 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
 
049c96
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
049c96
-		exit(2);
049c96
+		return -1;
049c96
 
049c96
 	return 0;
049c96
 }
049c96
diff --git a/bridge/vlan.c b/bridge/vlan.c
049c96
index 83c4088..ba54b0e 100644
049c96
--- a/bridge/vlan.c
049c96
+++ b/bridge/vlan.c
049c96
@@ -69,7 +69,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);
049c96
@@ -96,7 +96,7 @@ static int vlan_modify(int cmd, int argc, char **argv)
049c96
 	addattr_nest_end(&req.n, afspec);
049c96
 
049c96
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
049c96
-		exit(2);
049c96
+		return -1;
049c96
 
049c96
 	return 0;
049c96
 }
049c96
diff --git a/ip/iproute.c b/ip/iproute.c
049c96
index 586039d..fbe5268 100644
049c96
--- a/ip/iproute.c
049c96
+++ b/ip/iproute.c
049c96
@@ -1030,7 +1030,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
049c96
 		req.r.rtm_family = AF_INET;
049c96
 
049c96
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
049c96
-		exit(2);
049c96
+		return -1;
049c96
 
049c96
 	return 0;
049c96
 }
049c96
-- 
049c96
1.8.3.1
049c96