lib: suppress error msg when filling the cache
Subsystems (3)
PATCH 1/1 lib: suppress error msg when filling the cache
Before the patch:
$ ip netns add foo $ ip link add name veth1 address 2a:a5:5c:b9:52:89 type veth peer name veth2 address 2a:a5:5c:b9:53:90 netns foo RTNETLINK answers: No such device RTNETLINK answers: No such device
But the command was successful. This may break script. Let's remove those error messages.
--- lib/ll_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ll_map.c +1 -1
@@ -177,7 +177,7 @@ static int ll_link_get(const char *name, int index)addattr_l (&req.n,sizeof (req),IFLA_IFNAME , name,strlen (name) +1 ); -if (rtnl_talk (&rth, &req.n, &answer) <0 ) +if (rtnl_talk_suppress_rtnl_errmsg (&rth, &req.n, &answer) <0 ) goto out;/* add entry to cache */
Signature · 1 line
2.21.0
Quoted 22 lines · Nicolas Dichtel
Before the patch:
$ ip netns add foo $ ip link add name veth1 address 2a:a5:5c:b9:52:89 type veth peer name veth2 address 2a:a5:5c:b9:53:90 netns foo RTNETLINK answers: No such device RTNETLINK answers: No such deviceBut the command was successful. This may break script. Let's remove those error messages.
Fixes 55870dfe7f8b ("Improve batch and dump times by caching link lookups")Reported-by Philippe Guibert <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>--- lib/ll_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/ll_map.c +0
-0
lib/ll_map.c static int ll_link_get(const char *name, int index) · line 183
Quoted 8 lines
lib/ll_map.c +1
-1@@ -177,7 +177,7 @@ static int ll_link_get(const char *name, int index)addattr_l (&req.n,sizeof (req),IFLA_IFNAME , name,strlen (name) +1 ); -if (rtnl_talk (&rth, &req.n, &answer) <0 ) +if (rtnl_talk_suppress_rtnl_errmsg (&rth, &req.n, &answer) <0 ) goto out;/* add entry to cache */
In general, ll_link_get suppressing the error message seems like the right thing to do.
For the example above, seems like nl_get_ll_addr_len is the cause of the error messages, and it should not be called for this use case (NEWLINK with NLM_F_CREATE set)
Quoted 35 lines · On Fri, 24 May 2019 10:08:28 -0600 David Ahern <[email protected]> wrote:
Quoted 22 lines · Nicolas Dichtel
Before the patch:
$ ip netns add foo $ ip link add name veth1 address 2a:a5:5c:b9:52:89 type veth peer name veth2 address 2a:a5:5c:b9:53:90 netns foo RTNETLINK answers: No such device RTNETLINK answers: No such deviceBut the command was successful. This may break script. Let's remove those error messages.
Fixes 55870dfe7f8b ("Improve batch and dump times by caching link lookups")Reported-by Philippe Guibert <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>--- lib/ll_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/ll_map.c +0
-0lib/ll_map.c static int ll_link_get(const char *name, int index) · line 183
Quoted 8 lines
lib/ll_map.c +1
-1@@ -177,7 +177,7 @@ static int ll_link_get(const char *name, int index)addattr_l (&req.n,sizeof (req),IFLA_IFNAME , name,strlen (name) +1 ); -if (rtnl_talk (&rth, &req.n, &answer) <0 ) +if (rtnl_talk_suppress_rtnl_errmsg (&rth, &req.n, &answer) <0 ) goto out;/* add entry to cache */ In general,
ll_link_getsuppressing the error message seems like the right thing to do.
Quoted 3 lines
For the example above, seems like
nl_get_ll_addr_lenis the cause of the error messages, and it should not be called for this use case (NEWLINK withNLM_F_CREATEset)
Agree. I merged the patch to ll_link_get but send another to avoid the cause of unnecessary query.
PATCH 1/1 iplink: don't try to get ll addr len when creating an iface
It will obviously fail. This is a follow up of the commit 757837230a65 ("lib: suppress error msg when filling the cache").
--- ip/iplink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ip/iplink.c +2 -1
@@ -945,7 +945,8 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)else if (!strcmp (name, dev)) name = dev; -if (dev && addr_len) { +if (dev && addr_len && + !(req->n.nlmsg_flags &NLM_F_CREATE )) {int halen =nl_get_ll_addr_len (dev);if (halen >=0 && halen != addr_len) {
Signature · 1 line
2.21.0
Re: [PATCH iproute2] iplink: don't try to get ll addr len when creating an iface
Quoted 5 lines · On Wed, 29 May 2019 16:42:10 +0200 Nicolas Dichtel <[email protected]>…
It will obviously fail. This is a follow up of the commit
757837230a65("lib: suppress error msg when filling the cache").Suggested-by David Ahern <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>
Looks good, thanks for following up.
Applied.