[PATCH] libiproute: fix filtering ip6 route by table id
Denys Vlasenko
vda.linux at googlemail.com
Thu Feb 16 11:16:11 UTC 2023
On Sun, Feb 12, 2023 at 5:30 AM Yousong Zhou <yszhou4tech at gmail.com> wrote:
>
> Otherwise
>
> - "ip -6 route show" shows routes from all tables
> - "ip -6 route show table 200" shows nothing
>
> function old new delta
> print_route 1962 1941 -21
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-21) Total: -21 bytes
>
> Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
> ---
> networking/libiproute/iproute.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
> index 5a972f8b2..cd77f642f 100644
> --- a/networking/libiproute/iproute.c
> +++ b/networking/libiproute/iproute.c
> @@ -111,15 +111,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
> if (r->rtm_flags & RTM_F_CLONED) {
> return 0;
> }
> - if (G_filter.tb == RT_TABLE_LOCAL) {
> - if (r->rtm_type != RTN_LOCAL) {
> - return 0;
> - }
> - } else if (G_filter.tb == RT_TABLE_MAIN) {
> - if (r->rtm_type == RTN_LOCAL) {
> - return 0;
> - }
> - } else {
> + if (G_filter.tb != tid) {
> return 0;
> }
> }
The very same code exists in current iproute2 git tree.
Is it also buggy in the same way?
iproute.c
static int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
{
struct rtmsg *r = NLMSG_DATA(n);
inet_prefix dst = { .family = r->rtm_family };
inet_prefix src = { .family = r->rtm_family };
inet_prefix via = { .family = r->rtm_family };
inet_prefix prefsrc = { .family = r->rtm_family };
__u32 table;
static int ip6_multiple_tables;
table = rtm_get_table(r, tb);
if (preferred_family != AF_UNSPEC && r->rtm_family != preferred_family)
return 0;
if (r->rtm_family == AF_INET6 && table != RT_TABLE_MAIN)
ip6_multiple_tables = 1;
if (filter.cloned == !(r->rtm_flags & RTM_F_CLONED))
return 0;
if (r->rtm_family == AF_INET6 && !ip6_multiple_tables) {
if (filter.tb) {
if (filter.tb == RT_TABLE_LOCAL) {
if (r->rtm_type != RTN_LOCAL)
return 0;
} else if (filter.tb == RT_TABLE_MAIN) {
if (r->rtm_type == RTN_LOCAL)
return 0;
} else {
return 0;
}
}
} else {
if (filter.tb > 0 && filter.tb != table)
return 0;
}
More information about the busybox
mailing list