aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-06-02 01:19:30 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-03 05:51:04 -0400
commitadf30907d63893e4208dfe3f5c88ae12bc2f25d5 (patch)
tree0f07542bb95de2ad537540868aba6cf87a86e17d /include
parent511c3f92ad5b6d9f8f6464be1b4f85f0422be91a (diff)
net: skb->dst accessors
Define three accessors to get/set dst attached to a skb struct dst_entry *skb_dst(const struct sk_buff *skb) void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) void skb_dst_drop(struct sk_buff *skb) This one should replace occurrences of : dst_release(skb->dst) skb->dst = NULL; Delete skb->dst field Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/skbuff.h13
-rw-r--r--include/net/dst.h12
-rw-r--r--include/net/inet6_hashtables.h2
-rw-r--r--include/net/inet_hashtables.h2
-rw-r--r--include/net/ip6_route.h2
-rw-r--r--include/net/xfrm.h4
6 files changed, 25 insertions, 10 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a3ae3c525833..9ef6eb20247b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -323,7 +323,6 @@ struct sk_buff {
323 struct net_device *dev; 323 struct net_device *dev;
324 324
325 union { 325 union {
326 struct dst_entry *dst;
327 unsigned long _skb_dst; 326 unsigned long _skb_dst;
328 }; 327 };
329#ifdef CONFIG_XFRM 328#ifdef CONFIG_XFRM
@@ -426,9 +425,19 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
426 enum dma_data_direction dir); 425 enum dma_data_direction dir);
427#endif 426#endif
428 427
428static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
429{
430 return (struct dst_entry *)skb->_skb_dst;
431}
432
433static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
434{
435 skb->_skb_dst = (unsigned long)dst;
436}
437
429static inline struct rtable *skb_rtable(const struct sk_buff *skb) 438static inline struct rtable *skb_rtable(const struct sk_buff *skb)
430{ 439{
431 return (struct rtable *)skb->_skb_dst; 440 return (struct rtable *)skb_dst(skb);
432} 441}
433 442
434extern void kfree_skb(struct sk_buff *skb); 443extern void kfree_skb(struct sk_buff *skb);
diff --git a/include/net/dst.h b/include/net/dst.h
index 6be3b082a070..7fc409c19b37 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -195,6 +195,12 @@ struct dst_entry * dst_clone(struct dst_entry * dst)
195} 195}
196 196
197extern void dst_release(struct dst_entry *dst); 197extern void dst_release(struct dst_entry *dst);
198static inline void skb_dst_drop(struct sk_buff *skb)
199{
200 if (skb->_skb_dst)
201 dst_release(skb_dst(skb));
202 skb->_skb_dst = 0UL;
203}
198 204
199/* Children define the path of the packet through the 205/* Children define the path of the packet through the
200 * Linux networking. Thus, destinations are stackable. 206 * Linux networking. Thus, destinations are stackable.
@@ -246,7 +252,7 @@ static inline void dst_negative_advice(struct dst_entry **dst_p)
246 252
247static inline void dst_link_failure(struct sk_buff *skb) 253static inline void dst_link_failure(struct sk_buff *skb)
248{ 254{
249 struct dst_entry * dst = skb->dst; 255 struct dst_entry *dst = skb_dst(skb);
250 if (dst && dst->ops && dst->ops->link_failure) 256 if (dst && dst->ops && dst->ops->link_failure)
251 dst->ops->link_failure(skb); 257 dst->ops->link_failure(skb);
252} 258}
@@ -265,13 +271,13 @@ static inline void dst_set_expires(struct dst_entry *dst, int timeout)
265/* Output packet to network from transport. */ 271/* Output packet to network from transport. */
266static inline int dst_output(struct sk_buff *skb) 272static inline int dst_output(struct sk_buff *skb)
267{ 273{
268 return skb->dst->output(skb); 274 return skb_dst(skb)->output(skb);
269} 275}
270 276
271/* Input packet from network to transport. */ 277/* Input packet from network to transport. */
272static inline int dst_input(struct sk_buff *skb) 278static inline int dst_input(struct sk_buff *skb)
273{ 279{
274 return skb->dst->input(skb); 280 return skb_dst(skb)->input(skb);
275} 281}
276 282
277static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie) 283static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie)
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index f74665d7bea8..22c73a77cd99 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -100,7 +100,7 @@ static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo,
100 100
101 if (unlikely(sk = skb_steal_sock(skb))) 101 if (unlikely(sk = skb_steal_sock(skb)))
102 return sk; 102 return sk;
103 else return __inet6_lookup(dev_net(skb->dst->dev), hashinfo, 103 else return __inet6_lookup(dev_net(skb_dst(skb)->dev), hashinfo,
104 &ipv6_hdr(skb)->saddr, sport, 104 &ipv6_hdr(skb)->saddr, sport,
105 &ipv6_hdr(skb)->daddr, ntohs(dport), 105 &ipv6_hdr(skb)->daddr, ntohs(dport),
106 inet6_iif(skb)); 106 inet6_iif(skb));
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index a44e2248b2ef..d522dcf3031a 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -385,7 +385,7 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
385 if (unlikely(sk = skb_steal_sock(skb))) 385 if (unlikely(sk = skb_steal_sock(skb)))
386 return sk; 386 return sk;
387 else 387 else
388 return __inet_lookup(dev_net(skb->dst->dev), hashinfo, 388 return __inet_lookup(dev_net(skb_dst(skb)->dev), hashinfo,
389 iph->saddr, sport, 389 iph->saddr, sport,
390 iph->daddr, dport, inet_iif(skb)); 390 iph->daddr, dport, inet_iif(skb));
391} 391}
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 5f53db7e4e57..0e1b8aebaff8 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -142,7 +142,7 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
142 142
143static inline int ipv6_unicast_destination(struct sk_buff *skb) 143static inline int ipv6_unicast_destination(struct sk_buff *skb)
144{ 144{
145 struct rt6_info *rt = (struct rt6_info *) skb->dst; 145 struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);
146 146
147 return rt->rt6i_flags & RTF_LOCAL; 147 return rt->rt6i_flags & RTF_LOCAL;
148} 148}
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 2e9f5c0018ae..736bca450886 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -994,7 +994,7 @@ static inline int __xfrm_policy_check2(struct sock *sk, int dir,
994 return __xfrm_policy_check(sk, ndir, skb, family); 994 return __xfrm_policy_check(sk, ndir, skb, family);
995 995
996 return (!net->xfrm.policy_count[dir] && !skb->sp) || 996 return (!net->xfrm.policy_count[dir] && !skb->sp) ||
997 (skb->dst->flags & DST_NOPOLICY) || 997 (skb_dst(skb)->flags & DST_NOPOLICY) ||
998 __xfrm_policy_check(sk, ndir, skb, family); 998 __xfrm_policy_check(sk, ndir, skb, family);
999} 999}
1000 1000
@@ -1048,7 +1048,7 @@ static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family)
1048 struct net *net = dev_net(skb->dev); 1048 struct net *net = dev_net(skb->dev);
1049 1049
1050 return !net->xfrm.policy_count[XFRM_POLICY_OUT] || 1050 return !net->xfrm.policy_count[XFRM_POLICY_OUT] ||
1051 (skb->dst->flags & DST_NOXFRM) || 1051 (skb_dst(skb)->flags & DST_NOXFRM) ||
1052 __xfrm_route_forward(skb, family); 1052 __xfrm_route_forward(skb, family);
1053} 1053}
1054 1054