netdev
[Top] [All Lists]

[PATCH] rtnetlink & address family problem

To: Andrew Morton <akpm@xxxxxxxx>
Subject: [PATCH] rtnetlink & address family problem
From: Michal Ludvig <mludvig@xxxxxxx>
Date: Fri, 03 Dec 2004 18:43:16 +0100
Cc: netdev@xxxxxxxxxxx, Jan Kara <jack@xxxxxxx>
Organization: SuSE CR, s.r.o.
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8a4) Gecko/20040927
Hi,

running 'ip -6 addr flush dev eth0' on a kernel without IPv6 support
flushes *all* addresses from the interface, even those IPv4 ones,
because the unsupported protocol is substituted by PF_UNSPEC.
IMHO it should better return with an error EAFNOSUPPORT.

Attached patch fixes it. Please apply.

BTW Credits to Jan Kara <jack@xxxxxxx> for discovering and analysing
this bug.

Michal Ludvig
-- 
SUSE Labs                    mludvig@xxxxxxx
(+420) 296.542.396        http://www.suse.cz
Personal homepage http://www.logix.cz/michal
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/12/03 18:06:31+01:00 michal@xxxxxxxx 
#   Return EAFNOSUPPORT if requested operation on unsupported family.
#   
#   Signed-off-by: Michal Ludvig <michal@xxxxxxxx>
# 
# net/core/rtnetlink.c
#   2004/12/03 18:05:49+01:00 michal@xxxxxxxx +4 -2
#   Return EAFNOSUPPORT if requested operation on unsupported family.
# 
diff -Nru a/net/core/rtnetlink.c b/net/core/rtnetlink.c
--- a/net/core/rtnetlink.c      2004-12-03 18:30:33 +01:00
+++ b/net/core/rtnetlink.c      2004-12-03 18:30:33 +01:00
@@ -477,8 +477,10 @@
        }
 
        link_tab = rtnetlink_links[family];
-       if (link_tab == NULL)
-               link_tab = rtnetlink_links[PF_UNSPEC];
+       if (link_tab == NULL) {
+               *errp = -EAFNOSUPPORT;
+               return -1;
+       }
        link = &link_tab[type];
 
        sz_idx = type>>2;
<Prev in Thread] Current Thread [Next in Thread>