]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - net/ipv4/ip_output.c
net: Do delayed neigh confirmation.
[mirror_ubuntu-zesty-kernel.git] / net / ipv4 / ip_output.c
index 451f97c42eb40fa14987602fafa31da79911acff..cc52679790b2a6608c08ddbac0e93b34f149592e 100644 (file)
@@ -113,19 +113,6 @@ int ip_local_out(struct sk_buff *skb)
 }
 EXPORT_SYMBOL_GPL(ip_local_out);
 
-/* dev_loopback_xmit for use with netfilter. */
-static int ip_dev_loopback_xmit(struct sk_buff *newskb)
-{
-       skb_reset_mac_header(newskb);
-       __skb_pull(newskb, skb_network_offset(newskb));
-       newskb->pkt_type = PACKET_LOOPBACK;
-       newskb->ip_summed = CHECKSUM_UNNECESSARY;
-       WARN_ON(!skb_dst(newskb));
-       skb_dst_force(newskb);
-       netif_rx_ni(newskb);
-       return 0;
-}
-
 static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst)
 {
        int ttl = inet->uc_ttl;
@@ -183,6 +170,7 @@ static inline int ip_finish_output2(struct sk_buff *skb)
        struct net_device *dev = dst->dev;
        unsigned int hh_len = LL_RESERVED_SPACE(dev);
        struct neighbour *neigh;
+       u32 nexthop;
 
        if (rt->rt_type == RTN_MULTICAST) {
                IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUTMCAST, skb->len);
@@ -200,19 +188,22 @@ static inline int ip_finish_output2(struct sk_buff *skb)
                }
                if (skb->sk)
                        skb_set_owner_w(skb2, skb->sk);
-               kfree_skb(skb);
+               consume_skb(skb);
                skb = skb2;
        }
 
-       rcu_read_lock();
-       neigh = dst_get_neighbour_noref(dst);
+       rcu_read_lock_bh();
+       nexthop = rt->rt_gateway ? rt->rt_gateway : ip_hdr(skb)->daddr;
+       neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
+       if (unlikely(!neigh))
+               neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
        if (neigh) {
-               int res = neigh_output(neigh, skb);
+               int res = dst_neigh_output(dst, neigh, skb);
 
-               rcu_read_unlock();
+               rcu_read_unlock_bh();
                return res;
        }
-       rcu_read_unlock();
+       rcu_read_unlock_bh();
 
        net_dbg_ratelimited("%s: No header cache and no neighbour!\n",
                            __func__);
@@ -281,7 +272,7 @@ int ip_mc_output(struct sk_buff *skb)
                        if (newskb)
                                NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
                                        newskb, NULL, newskb->dev,
-                                       ip_dev_loopback_xmit);
+                                       dev_loopback_xmit);
                }
 
                /* Multicasts with ttl 0 must not go beyond the host */
@@ -296,7 +287,7 @@ int ip_mc_output(struct sk_buff *skb)
                struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
                if (newskb)
                        NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, newskb,
-                               NULL, newskb->dev, ip_dev_loopback_xmit);
+                               NULL, newskb->dev, dev_loopback_xmit);
        }
 
        return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, NULL,
@@ -709,7 +700,7 @@ slow_path:
 
                IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES);
        }
-       kfree_skb(skb);
+       consume_skb(skb);
        IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS);
        return err;
 
@@ -1472,13 +1463,14 @@ static int ip_reply_glue_bits(void *dptr, char *to, int offset,
 
 /*
  *     Generic function to send a packet as reply to another packet.
- *     Used to send TCP resets so far. ICMP should use this function too.
+ *     Used to send TCP resets so far.
  *
  *     Should run single threaded per socket because it uses the sock
  *             structure to pass arguments.
  */
-void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
-                  const struct ip_reply_arg *arg, unsigned int len)
+void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
+                          __be32 saddr, const struct ip_reply_arg *arg,
+                          unsigned int len)
 {
        struct inet_sock *inet = inet_sk(sk);
        struct ip_options_data replyopts;
@@ -1504,7 +1496,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
                           RT_TOS(arg->tos),
                           RT_SCOPE_UNIVERSE, sk->sk_protocol,
                           ip_reply_arg_flowi_flags(arg),
-                          daddr, rt->rt_spec_dst,
+                          daddr, saddr,
                           tcp_hdr(skb)->source, tcp_hdr(skb)->dest);
        security_skb_classify_flow(skb, flowi4_to_flowi(&fl4));
        rt = ip_route_output_key(sock_net(sk), &fl4);