Skip to contentSkip to conversation

iproute: Remove useless check for nexthop keyword when setting RTA_OIF

PATCH In review Jakub Sitnicki 2 participants 2 messages Jun 7, 2017 – Jun 14, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iproute: Remove useless check for nexthop keyword when setting RTA_OIF

When modifying a route we set the RTA_OIF attribute only if a device was specified with "dev" or "oif" keyword. But for some unknown reason we earlier alternatively check also for the presence of "nexthop" keyword, even though it has no effect. So remove the pointless check.

---
 ip/iproute.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
ip/iproute.c +5 -7
index b4ca291..4fd36a1 100644
@@ -1241,16 +1241,14 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
 	if (!dst_ok)
 		usage();
 
-	if (d || nhs_ok)  {
+	if (d) {
 		int idx;
 
-		if (d) {
-			if ((idx = ll_name_to_index(d)) == 0) {
-				fprintf(stderr, "Cannot find device \"%s\"\n", d);
-				return -1;
-			}
-			addattr32(&req.n, sizeof(req), RTA_OIF, idx);
+		if ((idx = ll_name_to_index(d)) == 0) {
+			fprintf(stderr, "Cannot find device \"%s\"\n", d);
+			return -1;
 		}
+		addattr32(&req.n, sizeof(req), RTA_OIF, idx);
 	}
 
 	if (mxrta->rta_len > RTA_LENGTH(0)) {
Signature · 1 line
2.9.4
#1 lore raw
Quoted 6 lines · On Wed, 7 Jun 2017 15:23:13 +0200 Jakub Sitnicki <[email protected]> wrote:

When modifying a route we set the RTA_OIF attribute only if a device was specified with "dev" or "oif" keyword. But for some unknown reason we earlier alternatively check also for the presence of "nexthop" keyword, even though it has no effect. So remove the pointless check.

Makes sense, applied.