diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-23 19:29:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-23 19:36:26 -0400 |
commit | 92101b3b2e3178087127709a556b091dae314e9e (patch) | |
tree | 06359f8823da3ed7617c5ea78e4a56bc5e958fea /net/ipv4 | |
parent | fe3edf45792a7d2f0edff4e2fcdd9a84c1a388a0 (diff) |
ipv4: Prepare for change of rt->rt_iif encoding.
Use inet_iif() consistently, and for TCP record the input interface of
cached RX dst in inet sock.
rt->rt_iif is going to be encoded differently, so that we can
legitimately cache input routes in the FIB info more aggressively.
When the input interface is "use SKB device index" the rt->rt_iif will
be set to zero.
This forces us to move the TCP RX dst cache installation into the ipv4
specific code, and as well it should since doing the route caching for
ipv6 is pointless at the moment since it is not inspected in the ipv6
input paths yet.
Also, remove the unlikely on dst->obsolete, all ipv4 dsts have
obsolete set to a non-zero value to force invocation of the check
callback.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/icmp.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 5 | ||||
-rw-r--r-- | net/ipv4/route.c | 2 | ||||
-rw-r--r-- | net/ipv4/tcp_input.c | 12 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 24 |
5 files changed, 22 insertions, 23 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index f2a06beffbd3..f2eccd531746 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -571,7 +571,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
571 | rcu_read_lock(); | 571 | rcu_read_lock(); |
572 | if (rt_is_input_route(rt) && | 572 | if (rt_is_input_route(rt) && |
573 | net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr) | 573 | net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr) |
574 | dev = dev_get_by_index_rcu(net, rt->rt_iif); | 574 | dev = dev_get_by_index_rcu(net, inet_iif(skb_in)); |
575 | 575 | ||
576 | if (dev) | 576 | if (dev) |
577 | saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); | 577 | saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index de29f46f68b0..5eea4a811042 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -1027,10 +1027,9 @@ e_inval: | |||
1027 | void ipv4_pktinfo_prepare(struct sk_buff *skb) | 1027 | void ipv4_pktinfo_prepare(struct sk_buff *skb) |
1028 | { | 1028 | { |
1029 | struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb); | 1029 | struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb); |
1030 | const struct rtable *rt = skb_rtable(skb); | ||
1031 | 1030 | ||
1032 | if (rt) { | 1031 | if (skb_rtable(skb)) { |
1033 | pktinfo->ipi_ifindex = rt->rt_iif; | 1032 | pktinfo->ipi_ifindex = inet_iif(skb); |
1034 | pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); | 1033 | pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); |
1035 | } else { | 1034 | } else { |
1036 | pktinfo->ipi_ifindex = 0; | 1035 | pktinfo->ipi_ifindex = 0; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 34017be87c85..f6be78119396 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -848,7 +848,7 @@ void ip_rt_send_redirect(struct sk_buff *skb) | |||
848 | if (log_martians && | 848 | if (log_martians && |
849 | peer->rate_tokens == ip_rt_redirect_number) | 849 | peer->rate_tokens == ip_rt_redirect_number) |
850 | net_warn_ratelimited("host %pI4/if%d ignores redirects for %pI4 to %pI4\n", | 850 | net_warn_ratelimited("host %pI4/if%d ignores redirects for %pI4 to %pI4\n", |
851 | &ip_hdr(skb)->saddr, rt->rt_iif, | 851 | &ip_hdr(skb)->saddr, inet_iif(skb), |
852 | &ip_hdr(skb)->daddr, &rt->rt_gateway); | 852 | &ip_hdr(skb)->daddr, &rt->rt_gateway); |
853 | #endif | 853 | #endif |
854 | } | 854 | } |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 21d7f8f3a7a5..3e07a64ca44e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -5391,18 +5391,6 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
5391 | { | 5391 | { |
5392 | struct tcp_sock *tp = tcp_sk(sk); | 5392 | struct tcp_sock *tp = tcp_sk(sk); |
5393 | 5393 | ||
5394 | if (sk->sk_rx_dst) { | ||
5395 | struct dst_entry *dst = sk->sk_rx_dst; | ||
5396 | if (unlikely(dst->obsolete)) { | ||
5397 | if (dst->ops->check(dst, 0) == NULL) { | ||
5398 | dst_release(dst); | ||
5399 | sk->sk_rx_dst = NULL; | ||
5400 | } | ||
5401 | } | ||
5402 | } | ||
5403 | if (unlikely(sk->sk_rx_dst == NULL)) | ||
5404 | sk->sk_rx_dst = dst_clone(skb_dst(skb)); | ||
5405 | |||
5406 | /* | 5394 | /* |
5407 | * Header prediction. | 5395 | * Header prediction. |
5408 | * The code loosely follows the one in the famous | 5396 | * The code loosely follows the one in the famous |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index bc5432e3c778..3e30548ac32a 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1618,6 +1618,20 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
1618 | 1618 | ||
1619 | if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ | 1619 | if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ |
1620 | sock_rps_save_rxhash(sk, skb); | 1620 | sock_rps_save_rxhash(sk, skb); |
1621 | if (sk->sk_rx_dst) { | ||
1622 | struct dst_entry *dst = sk->sk_rx_dst; | ||
1623 | if (dst->ops->check(dst, 0) == NULL) { | ||
1624 | dst_release(dst); | ||
1625 | sk->sk_rx_dst = NULL; | ||
1626 | } | ||
1627 | } | ||
1628 | if (unlikely(sk->sk_rx_dst == NULL)) { | ||
1629 | struct inet_sock *icsk = inet_sk(sk); | ||
1630 | struct rtable *rt = skb_rtable(skb); | ||
1631 | |||
1632 | sk->sk_rx_dst = dst_clone(&rt->dst); | ||
1633 | icsk->rx_dst_ifindex = inet_iif(skb); | ||
1634 | } | ||
1621 | if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) { | 1635 | if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) { |
1622 | rsk = sk; | 1636 | rsk = sk; |
1623 | goto reset; | 1637 | goto reset; |
@@ -1700,14 +1714,12 @@ void tcp_v4_early_demux(struct sk_buff *skb) | |||
1700 | skb->destructor = sock_edemux; | 1714 | skb->destructor = sock_edemux; |
1701 | if (sk->sk_state != TCP_TIME_WAIT) { | 1715 | if (sk->sk_state != TCP_TIME_WAIT) { |
1702 | struct dst_entry *dst = sk->sk_rx_dst; | 1716 | struct dst_entry *dst = sk->sk_rx_dst; |
1717 | struct inet_sock *icsk = inet_sk(sk); | ||
1703 | if (dst) | 1718 | if (dst) |
1704 | dst = dst_check(dst, 0); | 1719 | dst = dst_check(dst, 0); |
1705 | if (dst) { | 1720 | if (dst && |
1706 | struct rtable *rt = (struct rtable *) dst; | 1721 | icsk->rx_dst_ifindex == dev->ifindex) |
1707 | 1722 | skb_dst_set_noref(skb, dst); | |
1708 | if (rt->rt_iif == dev->ifindex) | ||
1709 | skb_dst_set_noref(skb, dst); | ||
1710 | } | ||
1711 | } | 1723 | } |
1712 | } | 1724 | } |
1713 | } | 1725 | } |