[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] iproute: ensure scope is correctly initialised
From: Natanael Copa <ncopa () alpinelinux ! org>
Date: 2016-08-06 10:56:05
Message-ID: 20160806125605.5ec8467f () ncopa-desktop ! copa ! dup ! pw
[Download RAW message or body]
On Fri, 05 Aug 2016 19:39:31 +0100
Ron Yorston <rmy@pobox.com> wrote:
> Code in iproute.c attempted to avoid assigning values to structure
> elements which were know to be zero unless the value to be assigned
> was non-zero.
>
> Commit ce4bc1ed added some more such cases. However, the treatment
> of req.r.rtm_scope was incorrect. Although this saved a few bytes it
> resulted in incorrect behaviour like:
>
> $ sudo busybox ip route add 192.168.0.0/24 via 10.98.106.9 dev wlan0
> ip: RTNETLINK answers: Invalid argument
>
> In practice this attempt at optimisation results in no saving, so
> remove it.
>
> Reported-by: Natanael Copa <ncopa@alpinelinux.org>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
Acked-by: Natanael Copa <ncopa@alpinelinux.org>
We now use this in alpine linux and it works.
Thanks!
> ---
> networking/libiproute/iproute.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
> index e674e9a..8db9aef 100644
> --- a/networking/libiproute/iproute.c
> +++ b/networking/libiproute/iproute.c
> @@ -356,18 +356,13 @@ IF_FEATURE_IP_RULE(ARG_table,)
> req.n.nlmsg_flags = NLM_F_REQUEST | flags;
> req.n.nlmsg_type = cmd;
> req.r.rtm_family = preferred_family;
> - if (RT_TABLE_MAIN != 0) /* if it is zero, memset already did it */
> - req.r.rtm_table = RT_TABLE_MAIN;
> - if (RT_SCOPE_NOWHERE != 0)
> - req.r.rtm_scope = RT_SCOPE_NOWHERE;
> + req.r.rtm_table = RT_TABLE_MAIN;
> + req.r.rtm_scope = RT_SCOPE_NOWHERE;
>
> if (cmd != RTM_DELROUTE) {
> - if (RTPROT_BOOT != 0)
> - req.r.rtm_protocol = RTPROT_BOOT;
> - if (RT_SCOPE_UNIVERSE != 0)
> - req.r.rtm_scope = RT_SCOPE_UNIVERSE;
> - if (RTN_UNICAST != 0)
> - req.r.rtm_type = RTN_UNICAST;
> + req.r.rtm_protocol = RTPROT_BOOT;
> + req.r.rtm_scope = RT_SCOPE_UNIVERSE;
> + req.r.rtm_type = RTN_UNICAST;
> }
>
> mxrta->rta_type = RTA_METRICS;
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic