net: ipv6: Introduce ip6_sk_dst_hoplimit.
This replaces 6 identical code snippets with a call to a new static inline function. Signed-off-by: Lorenzo Colitti <lorenzo@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a22adce5f9
commit
5c98631cca
|
@ -306,11 +306,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 bool ipv6_addr_is_multicast(const struct in6_addr *addr)
|
|
||||||
{
|
|
||||||
return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
|
static inline bool ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
|
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
|
||||||
|
|
|
@ -583,6 +583,11 @@ static inline bool ipv6_addr_orchid(const struct in6_addr *a)
|
||||||
return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010);
|
return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool ipv6_addr_is_multicast(const struct in6_addr *addr)
|
||||||
|
{
|
||||||
|
return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void ipv6_addr_set_v4mapped(const __be32 addr,
|
static inline void ipv6_addr_set_v4mapped(const __be32 addr,
|
||||||
struct in6_addr *v4mapped)
|
struct in6_addr *v4mapped)
|
||||||
{
|
{
|
||||||
|
@ -664,6 +669,20 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt);
|
||||||
|
|
||||||
int ip6_dst_hoplimit(struct dst_entry *dst);
|
int ip6_dst_hoplimit(struct dst_entry *dst);
|
||||||
|
|
||||||
|
static inline int ip6_sk_dst_hoplimit(struct ipv6_pinfo *np, struct flowi6 *fl6,
|
||||||
|
struct dst_entry *dst)
|
||||||
|
{
|
||||||
|
int hlimit;
|
||||||
|
|
||||||
|
if (ipv6_addr_is_multicast(&fl6->daddr))
|
||||||
|
hlimit = np->mcast_hops;
|
||||||
|
else
|
||||||
|
hlimit = np->hop_limit;
|
||||||
|
if (hlimit < 0)
|
||||||
|
hlimit = ip6_dst_hoplimit(dst);
|
||||||
|
return hlimit;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Header manipulation
|
* Header manipulation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -493,12 +493,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
|
||||||
if (IS_ERR(dst))
|
if (IS_ERR(dst))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (ipv6_addr_is_multicast(&fl6.daddr))
|
hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
|
||||||
hlimit = np->mcast_hops;
|
|
||||||
else
|
|
||||||
hlimit = np->hop_limit;
|
|
||||||
if (hlimit < 0)
|
|
||||||
hlimit = ip6_dst_hoplimit(dst);
|
|
||||||
|
|
||||||
msg.skb = skb;
|
msg.skb = skb;
|
||||||
msg.offset = skb_network_offset(skb);
|
msg.offset = skb_network_offset(skb);
|
||||||
|
@ -593,12 +588,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
|
||||||
if (IS_ERR(dst))
|
if (IS_ERR(dst))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (ipv6_addr_is_multicast(&fl6.daddr))
|
hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
|
||||||
hlimit = np->mcast_hops;
|
|
||||||
else
|
|
||||||
hlimit = np->hop_limit;
|
|
||||||
if (hlimit < 0)
|
|
||||||
hlimit = ip6_dst_hoplimit(dst);
|
|
||||||
|
|
||||||
idev = __in6_dev_get(skb->dev);
|
idev = __in6_dev_get(skb->dev);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
|
|
||||||
#include <net/ipv6.h>
|
#include <net/ipv6.h>
|
||||||
#include <net/addrconf.h>
|
|
||||||
#include <net/rawv6.h>
|
#include <net/rawv6.h>
|
||||||
#include <net/transp_v6.h>
|
#include <net/transp_v6.h>
|
||||||
|
|
||||||
|
|
|
@ -168,12 +168,7 @@ int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
|
||||||
pfh.wcheck = 0;
|
pfh.wcheck = 0;
|
||||||
pfh.family = AF_INET6;
|
pfh.family = AF_INET6;
|
||||||
|
|
||||||
if (ipv6_addr_is_multicast(&fl6.daddr))
|
hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
|
||||||
hlimit = np->mcast_hops;
|
|
||||||
else
|
|
||||||
hlimit = np->hop_limit;
|
|
||||||
if (hlimit < 0)
|
|
||||||
hlimit = ip6_dst_hoplimit(dst);
|
|
||||||
|
|
||||||
lock_sock(sk);
|
lock_sock(sk);
|
||||||
err = ip6_append_data(sk, ping_getfrag, &pfh, len,
|
err = ip6_append_data(sk, ping_getfrag, &pfh, len,
|
||||||
|
|
|
@ -873,14 +873,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
|
||||||
err = PTR_ERR(dst);
|
err = PTR_ERR(dst);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (hlimit < 0) {
|
if (hlimit < 0)
|
||||||
if (ipv6_addr_is_multicast(&fl6.daddr))
|
hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
|
||||||
hlimit = np->mcast_hops;
|
|
||||||
else
|
|
||||||
hlimit = np->hop_limit;
|
|
||||||
if (hlimit < 0)
|
|
||||||
hlimit = ip6_dst_hoplimit(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tclass < 0)
|
if (tclass < 0)
|
||||||
tclass = np->tclass;
|
tclass = np->tclass;
|
||||||
|
|
|
@ -1232,14 +1232,8 @@ do_udp_sendmsg:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hlimit < 0) {
|
if (hlimit < 0)
|
||||||
if (ipv6_addr_is_multicast(&fl6.daddr))
|
hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
|
||||||
hlimit = np->mcast_hops;
|
|
||||||
else
|
|
||||||
hlimit = np->hop_limit;
|
|
||||||
if (hlimit < 0)
|
|
||||||
hlimit = ip6_dst_hoplimit(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tclass < 0)
|
if (tclass < 0)
|
||||||
tclass = np->tclass;
|
tclass = np->tclass;
|
||||||
|
|
|
@ -605,14 +605,8 @@ static int l2tp_ip6_sendmsg(struct kiocb *iocb, struct sock *sk,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hlimit < 0) {
|
if (hlimit < 0)
|
||||||
if (ipv6_addr_is_multicast(&fl6.daddr))
|
hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
|
||||||
hlimit = np->mcast_hops;
|
|
||||||
else
|
|
||||||
hlimit = np->hop_limit;
|
|
||||||
if (hlimit < 0)
|
|
||||||
hlimit = ip6_dst_hoplimit(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tclass < 0)
|
if (tclass < 0)
|
||||||
tclass = np->tclass;
|
tclass = np->tclass;
|
||||||
|
|
Loading…
Reference in New Issue