* [PATCH net iproute2 v3 1/2] mpls: always set type as RTN_UNICAST for route add/deletes
@ 2015-06-02 6:29 Roopa Prabhu
2015-06-02 21:22 ` Eric W. Biederman
0 siblings, 1 reply; 2+ messages in thread
From: Roopa Prabhu @ 2015-06-02 6:29 UTC (permalink / raw)
To: ebiederm, stephen; +Cc: davem, rshearma, netdev, vivek
From: Roopa Prabhu <roopa@cumulusnetworks.com>
Kernel expects type RTN_UNICAST for mpls route/dels
Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Robert Shearman <rshearma@brocade.com>
---
ip/iproute.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ip/iproute.c b/ip/iproute.c
index 670a4c6..71c088b 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -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;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net iproute2 v3 1/2] mpls: always set type as RTN_UNICAST for route add/deletes
2015-06-02 6:29 [PATCH net iproute2 v3 1/2] mpls: always set type as RTN_UNICAST for route add/deletes Roopa Prabhu
@ 2015-06-02 21:22 ` Eric W. Biederman
0 siblings, 0 replies; 2+ messages in thread
From: Eric W. Biederman @ 2015-06-02 21:22 UTC (permalink / raw)
To: Roopa Prabhu; +Cc: stephen, davem, rshearma, netdev, vivek
Roopa Prabhu <roopa@cumulusnetworks.com> writes:
> From: Roopa Prabhu <roopa@cumulusnetworks.com>
>
> 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
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
> Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
> Reviewed-by: Robert Shearman <rshearma@brocade.com>
> ---
> ip/iproute.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 670a4c6..71c088b 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-02 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02 6:29 [PATCH net iproute2 v3 1/2] mpls: always set type as RTN_UNICAST for route add/deletes Roopa Prabhu
2015-06-02 21:22 ` Eric W. Biederman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).