summaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki2008-06-25 09:26:47 +0200
committerYOSHIFUJI Hideaki2008-07-03 10:51:55 +0200
commitd68b82705a4a754e5773f412c6b8f1e65259bc8b (patch)
tree3bd32bb16b1e462d9c8be37f3b60ca2ec346d003 /net/ipv6/addrconf.c
parentniu: Add support for rx flow hash configuration. (diff)
downloadkernel-qcow2-linux-d68b82705a4a754e5773f412c6b8f1e65259bc8b.tar.gz
kernel-qcow2-linux-d68b82705a4a754e5773f412c6b8f1e65259bc8b.tar.xz
kernel-qcow2-linux-d68b82705a4a754e5773f412c6b8f1e65259bc8b.zip
ipv6: Do not assign non-valid address on interface.
Check the type of the address when adding a new one on interface. - the unspecified address (::) is always disallowed (RFC4291 2.5.2) - the loopback address is disallowed unless the interface is (one of) loopback (RFC4291 2.5.3). - multicast addresses are disallowed. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 84127d854cfc..8b6875f02039 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -578,6 +578,13 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
struct rt6_info *rt;
int hash;
int err = 0;
+ int addr_type = ipv6_addr_type(addr);
+
+ if (addr_type == IPV6_ADDR_ANY ||
+ addr_type & IPV6_ADDR_MULTICAST ||
+ (!(idev->dev->flags & IFF_LOOPBACK) &&
+ addr_type & IPV6_ADDR_LOOPBACK))
+ return ERR_PTR(-EADDRNOTAVAIL);
rcu_read_lock_bh();
if (idev->dead) {