Request for help with iproute2 bugs.
Subsystems (3)
Hello everybody!
This is a desperate attempt at finding people with time and motivation to look into bugs that has been reported against the iproute package in the debian bug tracking system. The reported bugs are usually not Debian-specific...
You'll find the complete list at http://bugs.debian.org/iproute
If you have comments, please email them to <bugnumber>@bugs.debian.org
Here's a list of interesting candidates, hopefully you'll find some useful comments if you follow the link (usually last comment at the bottom):
http://bugs.debian.org/532152 - incorrectly enumerates existing addresses.
iproute: 'ip addr flush' exits with error on first try
http://bugs.debian.org/525933 - many ip-addresses not handled gracefully.
iproute: "ip address" failes to list all IPs on an interface
http://bugs.debian.org/511720 - rip out flawed code in favor of sed ?
iproute: ss filter parsing flawed
http://bugs.debian.org/532727
iproute: "tc filter add ... protocol ip fw" broken?
http://bugs.debian.org/551937 - replacing ipv6 routes broken.
iproute: "ip -6 route replace ..." behaves as "ip -6 route add ..."
http://bugs.debian.org/498498 - ipv6 specific blackhole routing.
iproute: adding route blackholes doesn't work for IPv6
http://bugs.debian.org/508450 - weird behaviour confuses users.
ip tun add fails to create tunnel without remote, though no error
Signature · 1 line
Andreas Henriksson
Quoted 3 lines · Andreas Henriksson
http://bugs.debian.org/532727
iproute: "tc filter add ... protocol ip fw" broken?
This one is caused by a regression in iproute2. The attached patch should fix it.
commit b3d80773099c13f60598857901cb2724c210614f
Author: Patrick McHardy <[email protected]> Date: Mon Nov 23 12:00:46 2009 +0100
f_fw: fix compat mode
The kernel takes a lack of options as indication that the fw classifier should operate in compatibility mode, where marks are mapped directly to classids.
Commit e22b42a (tc mask patch) broke this by adding an empty TCA_OPTIONS attribute even if no handle is specified. Restore the old behaviour.
tc/f_fw.c +9 -5
@@ -38,15 +38,13 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **astruct tc_police tp;struct tcmsg *t =NLMSG_DATA (n);struct rtattr *tail; +__u32 mask =0 ; +int mask_set =0 ;memset (&tp,0 ,sizeof (tp)); - tail =NLMSG_TAIL (n); -addattr_l (n,4096 ,TCA_OPTIONS ,NULL ,0 ); -if (handle) {char *slash; -__u32 mask =0 ;if ((slash =strchr (handle,'/' )) !=NULL ) *slash ='\0' ;if (get_u32 (&t->tcm_handle, handle,0 )) {
@@ -58,13 +56,19 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **afprintf (stderr,"Illegal \"handle\" mask\n" );return -1 ; } -addattr32 (n,MAX_MSG ,TCA_FW_MASK , mask); + mask_set =1 ; } }if (argc ==0 )return 0 ; + tail =NLMSG_TAIL (n); +addattr_l (n,4096 ,TCA_OPTIONS ,NULL ,0 ); + +if (mask_set) +addattr32 (n,MAX_MSG ,TCA_FW_MASK , mask); +while (argc >0 ) {if (matches (*argv,"classid" ) ==0 ||matches (*argv,"flowid" ) ==0 ) {
Stephen Hemminger
AppliedQuoted 7 lines · On Mon, 23 Nov 2009 12:03:41 +0100 Patrick McHardy <[email protected]> wrote:
Quoted 3 lines · Andreas Henriksson
http://bugs.debian.org/532727
iproute: "tc filter add ... protocol ip fw" broken?This one is caused by a regression in iproute2. The attached patch should fix it.
applied
Quoted 11 lines · Andreas Henriksson
Hello everybody!
This is a desperate attempt at finding people with time and motivation to look into bugs that has been reported against the iproute package in the debian bug tracking system. The reported bugs are usually not Debian-specific...
You'll find the complete list at http://bugs.debian.org/iproute
If you have comments, please email them to <bugnumber>@bugs.debian.org
Quoted 5 lines
Here's a list of interesting candidates, hopefully you'll find some useful comments if you follow the link (usually last comment at the bottom):
http://bugs.debian.org/532152 - incorrectly enumerates existing addresses.
iproute: 'ip addr flush' exits with error on first try
I've taken a stab at this one.
To: Andreas Henriksson <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: [rfc] iproute2: flush secondary addresses before primary ones
Date: Thu, 03 Dec 2009 12:05:55 +1100
Unless promote_secondaries has been active deleting the primary address of an interface will automatically delete all the secondary addresses.
In the case where ip flush requests the primary then secondary addresses to be removed - which is the order the addresses are returned by the kernel - this will cause an error as by the time the request to remove a secondary address is made it will be missing as it will have been deleted in the course of deleting the primary address.
This approach to solving this problem orders requests for the deletion of secondary addresses before primary ones providing rtnl_dump_filter_l(), a version of rtnl_dump_filter() that iterates over a list of filters. And by providing two specialised filters print_addrinfo_secondary() and print_addrinfo_primary().
rtnl_dump_filter_l() first iterates over all addresses using print_addrinfo_secondary(), which appends secondary addresses to the request buffer. Then again using print_addrinfo_primary() which appends primary addresses.
This approach should work regardless of it promote_secondaries is active or not. And regardless of if any primary of secondary addresses are present or not.
---
include/libnetlink.h | 12 +++++++ ip/ipaddress.c | 43 +++++++++++++++++++++++++ lib/libnetlink.c | 84 +++++++++++++++++++++++++++++--------------------- 3 files changed, 104 insertions(+), 35 deletions(-)
I'm not sure if this is the right place for this change, but this patch seems worth posting for discussion.
lib/libnetlink.c +50 -34
@@ -172,11 +172,8 @@ int rtnl_dump_request(struct rtnl_handlereturn sendmsg (rth->fd, &msg,0 ); } -int rtnl_dump_filter (struct rtnl_handle *rth, -rtnl_filter_t filter, -void *arg1, -rtnl_filter_t junk, -void *arg2) +int rtnl_dump_filter_l (struct rtnl_handle *rth, +const struct rtnl_dump_filter_arg *arg) {struct sockaddr_nl nladdr;struct iovec iov;
@@ -191,7 +188,7 @@ int rtnl_dump_filter(struct rtnl_handle iov.iov_base = buf;while (1 ) {int status; -struct nlmsghdr *h; +const struct rtnl_dump_filter_arg *a; iov.iov_len =sizeof (buf); status =recvmsg (rth->fd, &msg,0 );
@@ -209,40 +206,45 @@ int rtnl_dump_filter(struct rtnl_handlereturn -1 ; } - h = (struct nlmsghdr *)buf; -while (NLMSG_OK (h, status)) { -int err; +for (a = arg; a->filter; a++) { +struct nlmsghdr *h = (struct nlmsghdr *)buf; -if (nladdr.nl_pid !=0 || - h->nlmsg_pid != rth->local.nl_pid || - h->nlmsg_seq != rth->dump) { -if (junk) { - err =junk (&nladdr, h, arg2); -if (err <0 ) -return err; +while (NLMSG_OK (h, status)) { +int err; + +if (nladdr.nl_pid !=0 || + h->nlmsg_pid != rth->local.nl_pid || + h->nlmsg_seq != rth->dump) { +if (a->junk) { + err = a->junk (&nladdr, h, + a->arg2); +if (err <0 ) +return err; + } + goto skip_it; } - goto skip_it; - } -if (h->nlmsg_type ==NLMSG_DONE ) -return 0 ; -if (h->nlmsg_type ==NLMSG_ERROR ) { -struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); -if (h->nlmsg_len <NLMSG_LENGTH (sizeof (struct nlmsgerr ))) { -fprintf (stderr,"ERROR truncated\n" ); - }else { - errno = -err->error; -perror ("RTNETLINK answers" ); +if (h->nlmsg_type ==NLMSG_DONE ) +return 0 ; +if (h->nlmsg_type ==NLMSG_ERROR ) { +struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); +if (h->nlmsg_len <NLMSG_LENGTH (sizeof (struct nlmsgerr ))) { +fprintf (stderr, +"ERROR truncated\n" ); + }else { + errno = -err->error; +perror ("RTNETLINK answers" ); + } +return -1 ; } -return -1 ; - } - err =filter (&nladdr, h, arg1); -if (err <0 ) -return err; + err = a->filter (&nladdr, h, a->arg1); +if (err <0 ) +return err; skip_it: - h =NLMSG_NEXT (h, status); - } + h =NLMSG_NEXT (h, status); + } + }while (0 );if (msg.msg_flags &MSG_TRUNC ) {fprintf (stderr,"Message truncated\n" );continue ;
@@ -254,6 +256,20 @@ skip_it: } } +int rtnl_dump_filter (struct rtnl_handle *rth, +rtnl_filter_t filter, +void *arg1, +rtnl_filter_t junk, +void *arg2) +{ +const struct rtnl_dump_filter_arg a[2 ] = { + { .filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2 }, + { .filter =NULL , .arg1 =NULL , .junk =NULL , .arg2 =NULL } + }; + +return rtnl_dump_filter_l (rth, a); +} + int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,
include/libnetlink.h +12 -0
@@ -27,10 +27,22 @@ extern int rtnl_dump_request(struct rtnltypedef int (*rtnl_filter_t )(const struct sockaddr_nl *,struct nlmsghdr *n,void *); + +struct rtnl_dump_filter_arg +{ +rtnl_filter_t filter; +void *arg1; +rtnl_filter_t junk; +void *arg2; +}; + +extern int rtnl_dump_filter_l (struct rtnl_handle *rth, +const struct rtnl_dump_filter_arg *arg);extern int rtnl_dump_filter (struct rtnl_handle *rth,rtnl_filter_t filter,void *arg1,rtnl_filter_t junk,void *arg2); + extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,
ip/ipaddress.c +42 -1
60 lines not on this page · raw message
Quoted 12 lines · Simon Horman
Quoted 11 lines · Andreas Henriksson
Hello everybody!
This is a desperate attempt at finding people with time and motivation to look into bugs that has been reported against the iproute package in the debian bug tracking system. The reported bugs are usually not Debian-specific...
You'll find the complete list at http://bugs.debian.org/iproute
If you have comments, please email them to <bugnumber>@bugs.debian.org
Quoted 8 lines
Quoted 5 lines
Here's a list of interesting candidates, hopefully you'll find some useful comments if you follow the link (usually last comment at the bottom):
http://bugs.debian.org/532152 - incorrectly enumerates existing addresses.
iproute: 'ip addr flush' exits with error on first tryI've taken a stab at this one.
Any feedback?
Quoted 256 lines
To: Andreas Henriksson <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: [rfc] iproute2: flush secondary addresses before primary ones
Date: Thu, 03 Dec 2009 12:05:55 +1100Unless
promote_secondarieshas been active deleting the primary address of an interface will automatically delete all the secondary addresses.In the case where ip flush requests the primary then secondary addresses to be removed - which is the order the addresses are returned by the kernel - this will cause an error as by the time the request to remove a secondary address is made it will be missing as it will have been deleted in the course of deleting the primary address.
This approach to solving this problem orders requests for the deletion of secondary addresses before primary ones providing
rtnl_dump_filter_l(), a version ofrtnl_dump_filter()that iterates over a list of filters. And by providing two specialised filtersprint_addrinfo_secondary()andprint_addrinfo_primary().
rtnl_dump_filter_l()first iterates over all addresses usingprint_addrinfo_secondary(), which appends secondary addresses to the request buffer. Then again usingprint_addrinfo_primary()which appends primary addresses.This approach should work regardless of it
promote_secondariesis active or not. And regardless of if any primary of secondary addresses are present or not.Signed-off-by Simon Horman <[email protected]>---
include/libnetlink.h | 12 +++++++ ip/ipaddress.c | 43 +++++++++++++++++++++++++ lib/libnetlink.c | 84 +++++++++++++++++++++++++++++--------------------- 3 files changed, 104 insertions(+), 35 deletions(-)I'm not sure if this is the right place for this change, but this patch seems worth posting for discussion.
Index:
iproute2/lib/libnetlink.c
===================================================================lib/libnetlink.c +50
-34@@ -172,11 +172,8 @@ int rtnl_dump_request(struct rtnl_handlereturn sendmsg (rth->fd, &msg,0 ); } -int rtnl_dump_filter (struct rtnl_handle *rth, -rtnl_filter_t filter, -void *arg1, -rtnl_filter_t junk, -void *arg2) +int rtnl_dump_filter_l (struct rtnl_handle *rth, +const struct rtnl_dump_filter_arg *arg) {struct sockaddr_nl nladdr;struct iovec iov;@@ -191,7 +188,7 @@ int rtnl_dump_filter(struct rtnl_handle iov.iov_base = buf;while (1 ) {int status; -struct nlmsghdr *h; +const struct rtnl_dump_filter_arg *a; iov.iov_len =sizeof (buf); status =recvmsg (rth->fd, &msg,0 );@@ -209,40 +206,45 @@ int rtnl_dump_filter(struct rtnl_handlereturn -1 ; } - h = (struct nlmsghdr *)buf; -while (NLMSG_OK (h, status)) { -int err; +for (a = arg; a->filter; a++) { +struct nlmsghdr *h = (struct nlmsghdr *)buf; -if (nladdr.nl_pid !=0 || - h->nlmsg_pid != rth->local.nl_pid || - h->nlmsg_seq != rth->dump) { -if (junk) { - err =junk (&nladdr, h, arg2); -if (err <0 ) -return err; +while (NLMSG_OK (h, status)) { +int err; + +if (nladdr.nl_pid !=0 || + h->nlmsg_pid != rth->local.nl_pid || + h->nlmsg_seq != rth->dump) { +if (a->junk) { + err = a->junk (&nladdr, h, + a->arg2); +if (err <0 ) +return err; + } + goto skip_it; } - goto skip_it; - } -if (h->nlmsg_type ==NLMSG_DONE ) -return 0 ; -if (h->nlmsg_type ==NLMSG_ERROR ) { -struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); -if (h->nlmsg_len <NLMSG_LENGTH (sizeof (struct nlmsgerr ))) { -fprintf (stderr,"ERROR truncated\n" ); - }else { - errno = -err->error; -perror ("RTNETLINK answers" ); +if (h->nlmsg_type ==NLMSG_DONE ) +return 0 ; +if (h->nlmsg_type ==NLMSG_ERROR ) { +struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); +if (h->nlmsg_len <NLMSG_LENGTH (sizeof (struct nlmsgerr ))) { +fprintf (stderr, +"ERROR truncated\n" ); + }else { + errno = -err->error; +perror ("RTNETLINK answers" ); + } +return -1 ; } -return -1 ; - } - err =filter (&nladdr, h, arg1); -if (err <0 ) -return err; + err = a->filter (&nladdr, h, a->arg1); +if (err <0 ) +return err; skip_it: - h =NLMSG_NEXT (h, status); - } + h =NLMSG_NEXT (h, status); + } + }while (0 );if (msg.msg_flags &MSG_TRUNC ) {fprintf (stderr,"Message truncated\n" );continue ;@@ -254,6 +256,20 @@ skip_it: } } +int rtnl_dump_filter (struct rtnl_handle *rth, +rtnl_filter_t filter, +void *arg1, +rtnl_filter_t junk, +void *arg2) +{ +const struct rtnl_dump_filter_arg a[2 ] = { + { .filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2 }, + { .filter =NULL , .arg1 =NULL , .junk =NULL , .arg2 =NULL } + }; + +return rtnl_dump_filter_l (rth, a); +} + int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,Index:
iproute2/include/libnetlink.h
===================================================================include/libnetlink.h +12
-0@@ -27,10 +27,22 @@ extern int rtnl_dump_request(struct rtnltypedef int (*rtnl_filter_t )(const struct sockaddr_nl *,struct nlmsghdr *n,void *); + +struct rtnl_dump_filter_arg +{ +rtnl_filter_t filter; +void *arg1; +rtnl_filter_t junk; +void *arg2; +}; + +extern int rtnl_dump_filter_l (struct rtnl_handle *rth, +const struct rtnl_dump_filter_arg *arg);extern int rtnl_dump_filter (struct rtnl_handle *rth,rtnl_filter_t filter,void *arg1,rtnl_filter_t junk,void *arg2); + extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,Index:
iproute2/ip/ipaddress.c
===================================================================ip/ipaddress.c +42
-1@@ -539,6 +539,27 @@ int print_addrinfo(const struct sockaddrreturn 0 ; } +int print_addrinfo_primary (const struct sockaddr_nl *who,struct nlmsghdr *n, +void *arg) +{ +struct ifaddrmsg *ifa =NLMSG_DATA (n); + +if (!ifa->ifa_flags &IFA_F_SECONDARY ) +return 0 ; + +return print_addrinfo (who, n, arg); +} + +int print_addrinfo_secondary (const struct sockaddr_nl *who,struct nlmsghdr *n, +void *arg) +{ +struct ifaddrmsg *ifa =NLMSG_DATA (n); + +if (ifa->ifa_flags &IFA_F_SECONDARY ) +return 0 ; + +return print_addrinfo (who, n, arg); +}struct nlmsg_list {@@ -700,12 +721,32 @@ static int ipaddr_list_or_flush(int argc filter.flushe =sizeof (flushb);while (round <MAX_ROUNDS ) { +const struct rtnl_dump_filter_arg a[3 ] = { + { + .filter = print_addrinfo_secondary, + .arg1 = stdout, + .junk =NULL , + .arg2 =NULL + }, + { + .filter = print_addrinfo_primary, + .arg1 = stdout, + .junk =NULL , + .arg2 =NULL + }, + { + .filter =NULL , + .arg1 =NULL , + .junk =NULL , + .arg2 =NULL + }, + };if (rtnl_wilddump_request (&rth, filter.family,RTM_GETADDR ) <0 ) {perror ("Cannot send dump request" );exit (1 ); } filter.flushed =0 ; -if (rtnl_dump_filter (&rth, print_addrinfo, stdout,NULL ,NULL ) <0 ) { +if (rtnl_dump_filter_l (&rth, a) <0 ) {fprintf (stderr,"Flush terminated\n" );exit (1 ); }
Re: Bug#532152: Request for help with iproute2 bugs.
Quoted 9 lines · Simon Horman
Quoted 6 lines · Simon Horman
Quoted 2 lines · Andreas Henriksson
http://bugs.debian.org/532152 - incorrectly enumerates existing addresses.
iproute: 'ip addr flush' exits with error on first tryI've taken a stab at this one.
Any feedback?
Looks good to me! Thanks for taking care of this.
Hopefully Stephen does his next round of reviews soon so this (and other pending patches) gets applied. We'll have to wait and see....
Signature · 2 lines
Regards, Andreas Henriksson
Quoted 12 lines · On Thu, 3 Dec 2009 12:08:27 +1100 Simon Horman <[email protected]> wrote:
Quoted 11 lines · Andreas Henriksson
Hello everybody!
This is a desperate attempt at finding people with time and motivation to look into bugs that has been reported against the iproute package in the debian bug tracking system. The reported bugs are usually not Debian-specific...
You'll find the complete list at http://bugs.debian.org/iproute
If you have comments, please email them to <bugnumber>@bugs.debian.org
Quoted 8 lines
Quoted 5 lines
Here's a list of interesting candidates, hopefully you'll find some useful comments if you follow the link (usually last comment at the bottom):
http://bugs.debian.org/532152 - incorrectly enumerates existing addresses.
iproute: 'ip addr flush' exits with error on first tryI've taken a stab at this one.
applied thanks