Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36393395 authored by David S. Miller's avatar David S. Miller
Browse files

ipv4: Handle PMTU in all ICMP error handlers.



With ip_rt_frag_needed() removed, we have to explicitly update PMTU
information in every ICMP error handler.

Create two helper functions to facilitate this.

1) ipv4_sk_update_pmtu()

   This updates the PMTU when we have a socket context to
   work with.

2) ipv4_update_pmtu()

   Raw version, used when no socket context is available.  For this
   interface, we essentially just pass in explicit arguments for
   the flow identity information we would have extracted from the
   socket.

   And you'll notice that ipv4_sk_update_pmtu() is simply implemented
   in terms of ipv4_update_pmtu()

Note that __ip_route_output_key() is used, rather than something like
ip_route_output_flow() or ip_route_output_key().  This is because we
absolutely do not want to end up with a route that does IPSEC
encapsulation and the like.  Instead, we only want the route that
would get us to the node described by the outermost IP header.

Reported-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b3908e22
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -215,6 +215,9 @@ static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 s
	return ip_route_input_common(skb, dst, src, tos, devin, true);
}

extern void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu,
			     int oif, u32 mark, u8 protocol, int flow_flags);
extern void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu);
extern void ip_rt_send_redirect(struct sk_buff *skb);

extern unsigned int		inet_addr_type(struct net *net, __be32 addr);
+1 −0
Original line number Diff line number Diff line
@@ -408,6 +408,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
		return;
	pr_debug("pmtu discovery on SA AH/%08x/%08x\n",
		 ntohl(ah->spi), ntohl(iph->daddr));
	ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
	xfrm_state_put(x);
}

+1 −0
Original line number Diff line number Diff line
@@ -494,6 +494,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
		return;
	NETDEBUG(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%08x\n",
		 ntohl(esph->spi), ntohl(iph->daddr));
	ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
	xfrm_state_put(x);
}

+10 −4
Original line number Diff line number Diff line
@@ -516,9 +516,6 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
		case ICMP_PORT_UNREACH:
			/* Impossible event. */
			return;
		case ICMP_FRAG_NEEDED:
			/* Soft state for pmtu is maintained by IP core. */
			return;
		default:
			/* All others are translated to HOST_UNREACH.
			   rfc2003 contains "deep thoughts" about NET_UNREACH,
@@ -538,7 +535,16 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
				flags & GRE_KEY ?
				*(((__be32 *)p) + (grehlen / 4) - 1) : 0,
				p[1]);
	if (t == NULL || t->parms.iph.daddr == 0 ||
	if (t == NULL)
		goto out;

	if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
		ipv4_update_pmtu(skb, dev_net(skb->dev), info,
				 t->parms.link, 0, IPPROTO_GRE, 0);
		goto out;
	}

	if (t->parms.iph.daddr == 0 ||
	    ipv4_is_multicast(t->parms.iph.daddr))
		goto out;

+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
		return;
	NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%pI4\n",
		 spi, &iph->daddr);
	ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
	xfrm_state_put(x);
}

Loading