mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 14:48:06 +00:00
[IPV6]: Define constants for link-local multicast addresses.
- Define link-local all-node / all-router multicast addresses. - Remove ipv6_addr_all_nodes() and ipv6_addr_all_routers(). Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
This commit is contained in:
parent
9acd9f3ae9
commit
f3ee4010e8
5 changed files with 24 additions and 48 deletions
|
@ -48,6 +48,14 @@ extern const struct in6_addr in6addr_any;
|
||||||
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
|
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
|
||||||
extern const struct in6_addr in6addr_loopback;
|
extern const struct in6_addr in6addr_loopback;
|
||||||
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
extern const struct in6_addr in6addr_linklocal_allnodes;
|
||||||
|
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
|
||||||
|
{ { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
||||||
|
extern const struct in6_addr in6addr_linklocal_allrouters;
|
||||||
|
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
|
||||||
|
{ { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 } } }
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sockaddr_in6 {
|
struct sockaddr_in6 {
|
||||||
unsigned short int sin6_family; /* AF_INET6 */
|
unsigned short int sin6_family; /* AF_INET6 */
|
||||||
|
|
|
@ -205,17 +205,6 @@ static inline void addrconf_addr_solict_mult(const struct in6_addr *addr,
|
||||||
htonl(0xFF000000) | addr->s6_addr32[3]);
|
htonl(0xFF000000) | addr->s6_addr32[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void ipv6_addr_all_nodes(struct in6_addr *addr)
|
|
||||||
{
|
|
||||||
ipv6_addr_set(addr, htonl(0xFF020000), 0, 0, htonl(0x1));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ipv6_addr_all_routers(struct in6_addr *addr)
|
|
||||||
{
|
|
||||||
ipv6_addr_set(addr, htonl(0xFF020000), 0, 0, htonl(0x2));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int ipv6_addr_is_multicast(const struct in6_addr *addr)
|
static inline int ipv6_addr_is_multicast(const struct in6_addr *addr)
|
||||||
{
|
{
|
||||||
return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
|
return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
|
||||||
|
|
|
@ -222,6 +222,8 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
|
||||||
/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
|
/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
|
||||||
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
||||||
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
|
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
|
||||||
|
const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
|
||||||
|
const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
|
||||||
|
|
||||||
/* Check if a valid qdisc is available */
|
/* Check if a valid qdisc is available */
|
||||||
static inline int addrconf_qdisc_ok(struct net_device *dev)
|
static inline int addrconf_qdisc_ok(struct net_device *dev)
|
||||||
|
@ -321,7 +323,6 @@ EXPORT_SYMBOL(in6_dev_finish_destroy);
|
||||||
static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct inet6_dev *ndev;
|
struct inet6_dev *ndev;
|
||||||
struct in6_addr maddr;
|
|
||||||
|
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
|
||||||
|
@ -406,8 +407,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
||||||
rcu_assign_pointer(dev->ip6_ptr, ndev);
|
rcu_assign_pointer(dev->ip6_ptr, ndev);
|
||||||
|
|
||||||
/* Join all-node multicast group */
|
/* Join all-node multicast group */
|
||||||
ipv6_addr_all_nodes(&maddr);
|
ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
|
||||||
ipv6_dev_mc_inc(dev, &maddr);
|
|
||||||
|
|
||||||
return ndev;
|
return ndev;
|
||||||
}
|
}
|
||||||
|
@ -433,18 +433,15 @@ static void dev_forward_change(struct inet6_dev *idev)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct inet6_ifaddr *ifa;
|
struct inet6_ifaddr *ifa;
|
||||||
struct in6_addr addr;
|
|
||||||
|
|
||||||
if (!idev)
|
if (!idev)
|
||||||
return;
|
return;
|
||||||
dev = idev->dev;
|
dev = idev->dev;
|
||||||
if (dev && (dev->flags & IFF_MULTICAST)) {
|
if (dev && (dev->flags & IFF_MULTICAST)) {
|
||||||
ipv6_addr_all_routers(&addr);
|
|
||||||
|
|
||||||
if (idev->cnf.forwarding)
|
if (idev->cnf.forwarding)
|
||||||
ipv6_dev_mc_inc(dev, &addr);
|
ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);
|
||||||
else
|
else
|
||||||
ipv6_dev_mc_dec(dev, &addr);
|
ipv6_dev_mc_dec(dev, &in6addr_linklocal_allrouters);
|
||||||
}
|
}
|
||||||
for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) {
|
for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) {
|
||||||
if (ifa->flags&IFA_F_TENTATIVE)
|
if (ifa->flags&IFA_F_TENTATIVE)
|
||||||
|
@ -2654,8 +2651,6 @@ static void addrconf_rs_timer(unsigned long data)
|
||||||
|
|
||||||
spin_lock(&ifp->lock);
|
spin_lock(&ifp->lock);
|
||||||
if (ifp->probes++ < ifp->idev->cnf.rtr_solicits) {
|
if (ifp->probes++ < ifp->idev->cnf.rtr_solicits) {
|
||||||
struct in6_addr all_routers;
|
|
||||||
|
|
||||||
/* The wait after the last probe can be shorter */
|
/* The wait after the last probe can be shorter */
|
||||||
addrconf_mod_timer(ifp, AC_RS,
|
addrconf_mod_timer(ifp, AC_RS,
|
||||||
(ifp->probes == ifp->idev->cnf.rtr_solicits) ?
|
(ifp->probes == ifp->idev->cnf.rtr_solicits) ?
|
||||||
|
@ -2663,9 +2658,7 @@ static void addrconf_rs_timer(unsigned long data)
|
||||||
ifp->idev->cnf.rtr_solicit_interval);
|
ifp->idev->cnf.rtr_solicit_interval);
|
||||||
spin_unlock(&ifp->lock);
|
spin_unlock(&ifp->lock);
|
||||||
|
|
||||||
ipv6_addr_all_routers(&all_routers);
|
ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
|
||||||
|
|
||||||
ndisc_send_rs(ifp->idev->dev, &ifp->addr, &all_routers);
|
|
||||||
} else {
|
} else {
|
||||||
spin_unlock(&ifp->lock);
|
spin_unlock(&ifp->lock);
|
||||||
/*
|
/*
|
||||||
|
@ -2806,16 +2799,12 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp)
|
||||||
ifp->idev->cnf.rtr_solicits > 0 &&
|
ifp->idev->cnf.rtr_solicits > 0 &&
|
||||||
(dev->flags&IFF_LOOPBACK) == 0 &&
|
(dev->flags&IFF_LOOPBACK) == 0 &&
|
||||||
(ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) {
|
(ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) {
|
||||||
struct in6_addr all_routers;
|
|
||||||
|
|
||||||
ipv6_addr_all_routers(&all_routers);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a host as already performed a random delay
|
* If a host as already performed a random delay
|
||||||
* [...] as part of DAD [...] there is no need
|
* [...] as part of DAD [...] there is no need
|
||||||
* to delay again before sending the first RS
|
* to delay again before sending the first RS
|
||||||
*/
|
*/
|
||||||
ndisc_send_rs(ifp->idev->dev, &ifp->addr, &all_routers);
|
ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
|
||||||
|
|
||||||
spin_lock_bh(&ifp->lock);
|
spin_lock_bh(&ifp->lock);
|
||||||
ifp->probes = 1;
|
ifp->probes = 1;
|
||||||
|
|
|
@ -1766,10 +1766,9 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct icmp6hdr *hdr;
|
struct icmp6hdr *hdr;
|
||||||
struct in6_addr *snd_addr;
|
const struct in6_addr *snd_addr;
|
||||||
struct in6_addr *addrp;
|
struct in6_addr *addrp;
|
||||||
struct in6_addr addr_buf;
|
struct in6_addr addr_buf;
|
||||||
struct in6_addr all_routers;
|
|
||||||
int err, len, payload_len, full_len;
|
int err, len, payload_len, full_len;
|
||||||
u8 ra[8] = { IPPROTO_ICMPV6, 0,
|
u8 ra[8] = { IPPROTO_ICMPV6, 0,
|
||||||
IPV6_TLV_ROUTERALERT, 2, 0, 0,
|
IPV6_TLV_ROUTERALERT, 2, 0, 0,
|
||||||
|
@ -1780,11 +1779,10 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
|
||||||
IP6_INC_STATS(__in6_dev_get(dev),
|
IP6_INC_STATS(__in6_dev_get(dev),
|
||||||
IPSTATS_MIB_OUTREQUESTS);
|
IPSTATS_MIB_OUTREQUESTS);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
snd_addr = addr;
|
if (type == ICMPV6_MGM_REDUCTION)
|
||||||
if (type == ICMPV6_MGM_REDUCTION) {
|
snd_addr = &in6addr_linklocal_allrouters;
|
||||||
snd_addr = &all_routers;
|
else
|
||||||
ipv6_addr_all_routers(&all_routers);
|
snd_addr = addr;
|
||||||
}
|
|
||||||
|
|
||||||
len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
|
len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
|
||||||
payload_len = len + sizeof(ra);
|
payload_len = len + sizeof(ra);
|
||||||
|
@ -2309,24 +2307,19 @@ void ipv6_mc_init_dev(struct inet6_dev *idev)
|
||||||
void ipv6_mc_destroy_dev(struct inet6_dev *idev)
|
void ipv6_mc_destroy_dev(struct inet6_dev *idev)
|
||||||
{
|
{
|
||||||
struct ifmcaddr6 *i;
|
struct ifmcaddr6 *i;
|
||||||
struct in6_addr maddr;
|
|
||||||
|
|
||||||
/* Deactivate timers */
|
/* Deactivate timers */
|
||||||
ipv6_mc_down(idev);
|
ipv6_mc_down(idev);
|
||||||
|
|
||||||
/* Delete all-nodes address. */
|
/* Delete all-nodes address. */
|
||||||
ipv6_addr_all_nodes(&maddr);
|
|
||||||
|
|
||||||
/* We cannot call ipv6_dev_mc_dec() directly, our caller in
|
/* We cannot call ipv6_dev_mc_dec() directly, our caller in
|
||||||
* addrconf.c has NULL'd out dev->ip6_ptr so in6_dev_get() will
|
* addrconf.c has NULL'd out dev->ip6_ptr so in6_dev_get() will
|
||||||
* fail.
|
* fail.
|
||||||
*/
|
*/
|
||||||
__ipv6_dev_mc_dec(idev, &maddr);
|
__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes);
|
||||||
|
|
||||||
if (idev->cnf.forwarding) {
|
if (idev->cnf.forwarding)
|
||||||
ipv6_addr_all_routers(&maddr);
|
__ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters);
|
||||||
__ipv6_dev_mc_dec(idev, &maddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
write_lock_bh(&idev->lock);
|
write_lock_bh(&idev->lock);
|
||||||
while ((i = idev->mc_list) != NULL) {
|
while ((i = idev->mc_list) != NULL) {
|
||||||
|
|
|
@ -818,10 +818,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
|
||||||
is_router = !!idev->cnf.forwarding;
|
is_router = !!idev->cnf.forwarding;
|
||||||
|
|
||||||
if (dad) {
|
if (dad) {
|
||||||
struct in6_addr maddr;
|
ndisc_send_na(dev, NULL, &in6addr_linklocal_allnodes, &msg->target,
|
||||||
|
|
||||||
ipv6_addr_all_nodes(&maddr);
|
|
||||||
ndisc_send_na(dev, NULL, &maddr, &msg->target,
|
|
||||||
is_router, 0, (ifp != NULL), 1);
|
is_router, 0, (ifp != NULL), 1);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue