Skip to contentSkip to conversation

mpls: always set type as RTN_UNICAST for route add/deletes

PATCH In review Roopa Prabhu 2 participants 2 messages Jun 2, 2015

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

PATCH v3 1/2 mpls: always set type as RTN_UNICAST for route add/deletes

From: Roopa Prabhu <[email protected]>

Kernel expects type RTN_UNICAST for mpls route/dels

---
 ip/iproute.c |    5 +++++
 1 file changed, 5 insertions(+)
ip/iproute.c +5 -0
index 670a4c6..71c088b 100644
@@ -803,6 +803,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 	int scope_ok = 0;
 	int table_ok = 0;
 	int raw = 0;
+	int type_ok = 0;
 
 	memset(&req, 0, sizeof(req));
 
@@ -1095,6 +1096,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 			    rtnl_rtntype_a2n(&type, *argv) == 0) {
 				NEXT_ARG();
 				req.r.rtm_type = type;
+				type_ok = 1;
 			}
 
 			if (matches(*argv, "help") == 0)
@@ -1160,6 +1162,9 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 		}
 	}
 
+	if (!type_ok && req.r.rtm_family == AF_MPLS)
+		req.r.rtm_type = RTN_UNICAST;
+
 	if (req.r.rtm_family == AF_UNSPEC)
 		req.r.rtm_family = AF_INET;
 
Signature · 1 line
1.7.10.4
Acked-by on v3 1/2
#1 lore raw
Quoted 3 lines · Roopa Prabhu

From: Roopa Prabhu <[email protected]>

Kernel expects type RTN_UNICAST for mpls route/dels

There almost a bug in this patch. You test req.r.rtm_family just before the default case of AF_UNSPEC is set to AF_INET. Which should not affect anything in this case but is down right confusing to think about, and could lead to maintenance problems in the future.

Otherwise

Quoted 36 lines
---
 ip/iproute.c |    5 +++++
 1 file changed, 5 insertions(+)
ip/iproute.c +5 -0
index 670a4c6..71c088b 100644
@@ -803,6 +803,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 	int scope_ok = 0;
 	int table_ok = 0;
 	int raw = 0;
+	int type_ok = 0;
 
 	memset(&req, 0, sizeof(req));
 
@@ -1095,6 +1096,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 			    rtnl_rtntype_a2n(&type, *argv) == 0) {
 				NEXT_ARG();
 				req.r.rtm_type = type;
+				type_ok = 1;
 			}
 
 			if (matches(*argv, "help") == 0)
@@ -1160,6 +1162,9 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 		}
 	}
 
+	if (!type_ok && req.r.rtm_family == AF_MPLS)
+		req.r.rtm_type = RTN_UNICAST;
+
 	if (req.r.rtm_family == AF_UNSPEC)
 		req.r.rtm_family = AF_INET;