On Fri, 05 Aug 2016 19:39:31 +0100
Ron Yorston <[email protected]> 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 <[email protected]>
> Signed-off-by: Ron Yorston <[email protected]>

Acked-by: Natanael Copa <[email protected]>

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
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to