]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
net: add dst_pending_confirm flag to skbuff
authorJulian Anastasov <ja@ssi.bg>
Mon, 6 Feb 2017 21:14:12 +0000 (23:14 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Feb 2017 18:07:46 +0000 (13:07 -0500)
Add new skbuff flag to allow protocols to confirm neighbour.
When same struct dst_entry can be used for many different
neighbours we can not use it for pending confirmations.

Add sock_confirm_neigh() helper to confirm the neighbour and
use it for IPv4, IPv6 and VRF before dst_neigh_output.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vrf.c
include/linux/skbuff.h
include/net/sock.h
net/ipv4/ip_output.c
net/ipv6/ip6_output.c

index 264fc1585b3c41df4054985abaafe175a47e37d3..630eafdb79e85bf84b1fe3c53dff2af5c968df17 100644 (file)
@@ -378,6 +378,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,
        if (unlikely(!neigh))
                neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
        if (!IS_ERR(neigh)) {
+               sock_confirm_neigh(skb, neigh);
                ret = dst_neigh_output(dst, neigh, skb);
                rcu_read_unlock_bh();
                return ret;
@@ -574,8 +575,10 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
        neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
        if (unlikely(!neigh))
                neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
-       if (!IS_ERR(neigh))
+       if (!IS_ERR(neigh)) {
+               sock_confirm_neigh(skb, neigh);
                ret = dst_neigh_output(dst, neigh, skb);
+       }
 
        rcu_read_unlock_bh();
 err:
index c6a78e1892b6b20d11314f94d6d6cef069580d45..f1adddc1c5ac67c350e280d89abc3f3c10e2dbac 100644 (file)
@@ -612,6 +612,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
  *     @wifi_acked_valid: wifi_acked was set
  *     @wifi_acked: whether frame was acked on wifi or not
  *     @no_fcs:  Request NIC to treat last 4 bytes as Ethernet FCS
+ *     @dst_pending_confirm: need to confirm neighbour
   *    @napi_id: id of the NAPI struct this skb came from
  *     @secmark: security marking
  *     @mark: Generic packet mark
@@ -741,6 +742,7 @@ struct sk_buff {
        __u8                    csum_level:2;
        __u8                    csum_bad:1;
 
+       __u8                    dst_pending_confirm:1;
 #ifdef CONFIG_IPV6_NDISC_NODETYPE
        __u8                    ndisc_nodetype:2;
 #endif
@@ -3698,6 +3700,16 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
        return skb->queue_mapping != 0;
 }
 
+static inline void skb_set_dst_pending_confirm(struct sk_buff *skb, u32 val)
+{
+       skb->dst_pending_confirm = val;
+}
+
+static inline bool skb_get_dst_pending_confirm(const struct sk_buff *skb)
+{
+       return skb->dst_pending_confirm != 0;
+}
+
 static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
 {
 #ifdef CONFIG_XFRM
index 85d856b94b4b949dc8377cf49a9114b957e39bcb..6f83e78eaa5a8928b34ecc63d49b1baf19722c10 100644 (file)
@@ -1821,6 +1821,20 @@ static inline void sk_dst_confirm(struct sock *sk)
                sk->sk_dst_pending_confirm = 1;
 }
 
+static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n)
+{
+       if (skb_get_dst_pending_confirm(skb)) {
+               struct sock *sk = skb->sk;
+               unsigned long now = jiffies;
+
+               /* avoid dirtying neighbour */
+               if (n->confirmed != now)
+                       n->confirmed = now;
+               if (sk && sk->sk_dst_pending_confirm)
+                       sk->sk_dst_pending_confirm = 0;
+       }
+}
+
 bool sk_mc_loop(struct sock *sk);
 
 static inline bool sk_can_gso(const struct sock *sk)
index b67719f459537d49d958de9874414ea868c4a8e1..c9fc32fa3272760ecce17841519753f892a1f66e 100644 (file)
@@ -222,7 +222,10 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s
        if (unlikely(!neigh))
                neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
        if (!IS_ERR(neigh)) {
-               int res = dst_neigh_output(dst, neigh, skb);
+               int res;
+
+               sock_confirm_neigh(skb, neigh);
+               res = dst_neigh_output(dst, neigh, skb);
 
                rcu_read_unlock_bh();
                return res;
index b6a94ff0bbd0d5f42c78b7bcd6ea9fbe5ac9a595..14d99fbf102e12b0952b97183689a65d219f4b3d 100644 (file)
@@ -119,6 +119,7 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *
        if (unlikely(!neigh))
                neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
        if (!IS_ERR(neigh)) {
+               sock_confirm_neigh(skb, neigh);
                ret = dst_neigh_output(dst, neigh, skb);
                rcu_read_unlock_bh();
                return ret;