forked from Minki/linux
c15b1ccadb
addrconf_join_solict and addrconf_join_anycast may cause actions which need rtnl locked, especially on first address creation. A new DAD state is introduced which defers processing of the initial DAD processing into a workqueue. To get rtnl lock we need to push the code paths which depend on those calls up to workqueues, specifically addrconf_verify and the DAD processing. (v2) addrconf_dad_failure needs to be queued up to the workqueue, too. This patch introduces a new DAD state and stop the DAD processing in the workqueue (this is because of the possible ipv6_del_addr processing which removes the solicited multicast address from the device). addrconf_verify_lock is removed, too. After the transition it is not needed any more. As we are not processing in bottom half anymore we need to be a bit more careful about disabling bottom half out when we lock spin_locks which are also used in bh. Relevant backtrace: [ 541.030090] RTNL: assertion failed at net/core/dev.c (4496) [ 541.031143] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G O 3.10.33-1-amd64-vyatta #1 [ 541.031145] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007 [ 541.031146] ffffffff8148a9f0 000000000000002f ffffffff813c98c1 ffff88007c4451f8 [ 541.031148] 0000000000000000 0000000000000000 ffffffff813d3540 ffff88007fc03d18 [ 541.031150] 0000880000000006 ffff88007c445000 ffffffffa0194160 0000000000000000 [ 541.031152] Call Trace: [ 541.031153] <IRQ> [<ffffffff8148a9f0>] ? dump_stack+0xd/0x17 [ 541.031180] [<ffffffff813c98c1>] ? __dev_set_promiscuity+0x101/0x180 [ 541.031183] [<ffffffff813d3540>] ? __hw_addr_create_ex+0x60/0xc0 [ 541.031185] [<ffffffff813cfe1a>] ? __dev_set_rx_mode+0xaa/0xc0 [ 541.031189] [<ffffffff813d3a81>] ? __dev_mc_add+0x61/0x90 [ 541.031198] [<ffffffffa01dcf9c>] ? igmp6_group_added+0xfc/0x1a0 [ipv6] [ 541.031208] [<ffffffff8111237b>] ? kmem_cache_alloc+0xcb/0xd0 [ 541.031212] [<ffffffffa01ddcd7>] ? ipv6_dev_mc_inc+0x267/0x300 [ipv6] [ 541.031216] [<ffffffffa01c2fae>] ? addrconf_join_solict+0x2e/0x40 [ipv6] [ 541.031219] [<ffffffffa01ba2e9>] ? ipv6_dev_ac_inc+0x159/0x1f0 [ipv6] [ 541.031223] [<ffffffffa01c0772>] ? addrconf_join_anycast+0x92/0xa0 [ipv6] [ 541.031226] [<ffffffffa01c311e>] ? __ipv6_ifa_notify+0x11e/0x1e0 [ipv6] [ 541.031229] [<ffffffffa01c3213>] ? ipv6_ifa_notify+0x33/0x50 [ipv6] [ 541.031233] [<ffffffffa01c36c8>] ? addrconf_dad_completed+0x28/0x100 [ipv6] [ 541.031241] [<ffffffff81075c1d>] ? task_cputime+0x2d/0x50 [ 541.031244] [<ffffffffa01c38d6>] ? addrconf_dad_timer+0x136/0x150 [ipv6] [ 541.031247] [<ffffffffa01c37a0>] ? addrconf_dad_completed+0x100/0x100 [ipv6] [ 541.031255] [<ffffffff8105313a>] ? call_timer_fn.isra.22+0x2a/0x90 [ 541.031258] [<ffffffffa01c37a0>] ? addrconf_dad_completed+0x100/0x100 [ipv6] Hunks and backtrace stolen from a patch by Stephen Hemminger. Reported-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
265 lines
6.1 KiB
C
265 lines
6.1 KiB
C
/*
|
|
* inet6 interface/address list definitions
|
|
* Linux INET6 implementation
|
|
*
|
|
* Authors:
|
|
* Pedro Roque <roque@di.fc.ul.pt>
|
|
*
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#ifndef _NET_IF_INET6_H
|
|
#define _NET_IF_INET6_H
|
|
|
|
#include <net/snmp.h>
|
|
#include <linux/ipv6.h>
|
|
|
|
/* inet6_dev.if_flags */
|
|
|
|
#define IF_RA_OTHERCONF 0x80
|
|
#define IF_RA_MANAGED 0x40
|
|
#define IF_RA_RCVD 0x20
|
|
#define IF_RS_SENT 0x10
|
|
#define IF_READY 0x80000000
|
|
|
|
/* prefix flags */
|
|
#define IF_PREFIX_ONLINK 0x01
|
|
#define IF_PREFIX_AUTOCONF 0x02
|
|
|
|
enum {
|
|
INET6_IFADDR_STATE_PREDAD,
|
|
INET6_IFADDR_STATE_DAD,
|
|
INET6_IFADDR_STATE_POSTDAD,
|
|
INET6_IFADDR_STATE_ERRDAD,
|
|
INET6_IFADDR_STATE_UP,
|
|
INET6_IFADDR_STATE_DEAD,
|
|
};
|
|
|
|
struct inet6_ifaddr {
|
|
struct in6_addr addr;
|
|
__u32 prefix_len;
|
|
|
|
/* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
|
|
__u32 valid_lft;
|
|
__u32 prefered_lft;
|
|
atomic_t refcnt;
|
|
spinlock_t lock;
|
|
spinlock_t state_lock;
|
|
|
|
int state;
|
|
|
|
__u32 flags;
|
|
__u8 dad_probes;
|
|
|
|
__u16 scope;
|
|
|
|
unsigned long cstamp; /* created timestamp */
|
|
unsigned long tstamp; /* updated timestamp */
|
|
|
|
struct delayed_work dad_work;
|
|
|
|
struct inet6_dev *idev;
|
|
struct rt6_info *rt;
|
|
|
|
struct hlist_node addr_lst;
|
|
struct list_head if_list;
|
|
|
|
struct list_head tmp_list;
|
|
struct inet6_ifaddr *ifpub;
|
|
int regen_count;
|
|
|
|
bool tokenized;
|
|
|
|
struct rcu_head rcu;
|
|
struct in6_addr peer_addr;
|
|
};
|
|
|
|
struct ip6_sf_socklist {
|
|
unsigned int sl_max;
|
|
unsigned int sl_count;
|
|
struct in6_addr sl_addr[0];
|
|
};
|
|
|
|
#define IP6_SFLSIZE(count) (sizeof(struct ip6_sf_socklist) + \
|
|
(count) * sizeof(struct in6_addr))
|
|
|
|
#define IP6_SFBLOCK 10 /* allocate this many at once */
|
|
|
|
struct ipv6_mc_socklist {
|
|
struct in6_addr addr;
|
|
int ifindex;
|
|
struct ipv6_mc_socklist __rcu *next;
|
|
rwlock_t sflock;
|
|
unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
|
|
struct ip6_sf_socklist *sflist;
|
|
struct rcu_head rcu;
|
|
};
|
|
|
|
struct ip6_sf_list {
|
|
struct ip6_sf_list *sf_next;
|
|
struct in6_addr sf_addr;
|
|
unsigned long sf_count[2]; /* include/exclude counts */
|
|
unsigned char sf_gsresp; /* include in g & s response? */
|
|
unsigned char sf_oldin; /* change state */
|
|
unsigned char sf_crcount; /* retrans. left to send */
|
|
};
|
|
|
|
#define MAF_TIMER_RUNNING 0x01
|
|
#define MAF_LAST_REPORTER 0x02
|
|
#define MAF_LOADED 0x04
|
|
#define MAF_NOREPORT 0x08
|
|
#define MAF_GSQUERY 0x10
|
|
|
|
struct ifmcaddr6 {
|
|
struct in6_addr mca_addr;
|
|
struct inet6_dev *idev;
|
|
struct ifmcaddr6 *next;
|
|
struct ip6_sf_list *mca_sources;
|
|
struct ip6_sf_list *mca_tomb;
|
|
unsigned int mca_sfmode;
|
|
unsigned char mca_crcount;
|
|
unsigned long mca_sfcount[2];
|
|
struct timer_list mca_timer;
|
|
unsigned int mca_flags;
|
|
int mca_users;
|
|
atomic_t mca_refcnt;
|
|
spinlock_t mca_lock;
|
|
unsigned long mca_cstamp;
|
|
unsigned long mca_tstamp;
|
|
};
|
|
|
|
/* Anycast stuff */
|
|
|
|
struct ipv6_ac_socklist {
|
|
struct in6_addr acl_addr;
|
|
int acl_ifindex;
|
|
struct ipv6_ac_socklist *acl_next;
|
|
};
|
|
|
|
struct ifacaddr6 {
|
|
struct in6_addr aca_addr;
|
|
struct inet6_dev *aca_idev;
|
|
struct rt6_info *aca_rt;
|
|
struct ifacaddr6 *aca_next;
|
|
int aca_users;
|
|
atomic_t aca_refcnt;
|
|
spinlock_t aca_lock;
|
|
unsigned long aca_cstamp;
|
|
unsigned long aca_tstamp;
|
|
};
|
|
|
|
#define IFA_HOST IPV6_ADDR_LOOPBACK
|
|
#define IFA_LINK IPV6_ADDR_LINKLOCAL
|
|
#define IFA_SITE IPV6_ADDR_SITELOCAL
|
|
|
|
struct ipv6_devstat {
|
|
struct proc_dir_entry *proc_dir_entry;
|
|
DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
|
|
DEFINE_SNMP_STAT_ATOMIC(struct icmpv6_mib_device, icmpv6dev);
|
|
DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib_device, icmpv6msgdev);
|
|
};
|
|
|
|
struct inet6_dev {
|
|
struct net_device *dev;
|
|
|
|
struct list_head addr_list;
|
|
|
|
struct ifmcaddr6 *mc_list;
|
|
struct ifmcaddr6 *mc_tomb;
|
|
spinlock_t mc_lock;
|
|
|
|
unsigned char mc_qrv; /* Query Robustness Variable */
|
|
unsigned char mc_gq_running;
|
|
unsigned char mc_ifc_count;
|
|
unsigned char mc_dad_count;
|
|
|
|
unsigned long mc_v1_seen; /* Max time we stay in MLDv1 mode */
|
|
unsigned long mc_qi; /* Query Interval */
|
|
unsigned long mc_qri; /* Query Response Interval */
|
|
unsigned long mc_maxdelay;
|
|
|
|
struct timer_list mc_gq_timer; /* general query timer */
|
|
struct timer_list mc_ifc_timer; /* interface change timer */
|
|
struct timer_list mc_dad_timer; /* dad complete mc timer */
|
|
|
|
struct ifacaddr6 *ac_list;
|
|
rwlock_t lock;
|
|
atomic_t refcnt;
|
|
__u32 if_flags;
|
|
int dead;
|
|
|
|
u8 rndid[8];
|
|
struct timer_list regen_timer;
|
|
struct list_head tempaddr_list;
|
|
|
|
struct in6_addr token;
|
|
|
|
struct neigh_parms *nd_parms;
|
|
struct ipv6_devconf cnf;
|
|
struct ipv6_devstat stats;
|
|
|
|
struct timer_list rs_timer;
|
|
__u8 rs_probes;
|
|
|
|
unsigned long tstamp; /* ipv6InterfaceTable update timestamp */
|
|
struct rcu_head rcu;
|
|
};
|
|
|
|
static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
|
|
{
|
|
/*
|
|
* +-------+-------+-------+-------+-------+-------+
|
|
* | 33 | 33 | DST13 | DST14 | DST15 | DST16 |
|
|
* +-------+-------+-------+-------+-------+-------+
|
|
*/
|
|
|
|
buf[0]= 0x33;
|
|
buf[1]= 0x33;
|
|
|
|
memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
|
|
}
|
|
|
|
static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf)
|
|
{
|
|
buf[0] = 0x00;
|
|
}
|
|
|
|
static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
|
|
const unsigned char *broadcast, char *buf)
|
|
{
|
|
unsigned char scope = broadcast[5] & 0xF;
|
|
|
|
buf[0] = 0; /* Reserved */
|
|
buf[1] = 0xff; /* Multicast QPN */
|
|
buf[2] = 0xff;
|
|
buf[3] = 0xff;
|
|
buf[4] = 0xff;
|
|
buf[5] = 0x10 | scope; /* scope from broadcast address */
|
|
buf[6] = 0x60; /* IPv6 signature */
|
|
buf[7] = 0x1b;
|
|
buf[8] = broadcast[8]; /* P_Key */
|
|
buf[9] = broadcast[9];
|
|
memcpy(buf + 10, addr->s6_addr + 6, 10);
|
|
}
|
|
|
|
static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
|
|
const unsigned char *broadcast, char *buf)
|
|
{
|
|
if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) {
|
|
memcpy(buf, broadcast, 4);
|
|
} else {
|
|
/* v4mapped? */
|
|
if ((addr->s6_addr32[0] | addr->s6_addr32[1] |
|
|
(addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0)
|
|
return -EINVAL;
|
|
memcpy(buf, &addr->s6_addr32[3], 4);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
#endif
|