Skip to content

Commit

Permalink
ipv4: Update MTU to all related cache entries in ip_rt_frag_needed()
Browse files Browse the repository at this point in the history
Add struct net_device parameter to ip_rt_frag_needed() and update MTU to
cache entries where ifindex is specified. This is similar to what is
already done in ip_rt_redirect().

Signed-off-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Timo Teras authored and David S. Miller committed Apr 29, 2008
1 parent 980c478 commit 0010e46
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extern int __ip_route_output_key(struct net *, struct rtable **, const struct f
extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp);
extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags);
extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin);
extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu);
extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev);
extern void ip_rt_send_redirect(struct sk_buff *skb);

extern unsigned inet_addr_type(struct net *net, __be32 addr);
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ static void icmp_unreach(struct sk_buff *skb)
NIPQUAD(iph->daddr));
} else {
info = ip_rt_frag_needed(net, iph,
ntohs(icmph->un.frag.mtu));
ntohs(icmph->un.frag.mtu),
skb->dev);
if (!info)
goto out;
}
Expand Down
38 changes: 22 additions & 16 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,34 +1430,40 @@ static inline unsigned short guess_mtu(unsigned short old_mtu)
}

unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
unsigned short new_mtu)
unsigned short new_mtu,
struct net_device *dev)
{
int i;
int i, k;
unsigned short old_mtu = ntohs(iph->tot_len);
struct rtable *rth;
int ikeys[2] = { dev->ifindex, 0 };
__be32 skeys[2] = { iph->saddr, 0, };
__be32 daddr = iph->daddr;
unsigned short est_mtu = 0;

if (ipv4_config.no_pmtu_disc)
return 0;

for (i = 0; i < 2; i++) {
unsigned hash = rt_hash(daddr, skeys[i], 0);
for (k = 0; k < 2; k++) {
for (i = 0; i < 2; i++) {
unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]);

rcu_read_lock();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
rth = rcu_dereference(rth->u.dst.rt_next)) {
if (rth->fl.fl4_dst == daddr &&
rth->fl.fl4_src == skeys[i] &&
rth->rt_dst == daddr &&
rth->rt_src == iph->saddr &&
rth->fl.iif == 0 &&
!(dst_metric_locked(&rth->u.dst, RTAX_MTU)) &&
net_eq(dev_net(rth->u.dst.dev), net) &&
rth->rt_genid == atomic_read(&rt_genid)) {
rcu_read_lock();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
rth = rcu_dereference(rth->u.dst.rt_next)) {
unsigned short mtu = new_mtu;

if (rth->fl.fl4_dst != daddr ||
rth->fl.fl4_src != skeys[i] ||
rth->rt_dst != daddr ||
rth->rt_src != iph->saddr ||
rth->fl.oif != ikeys[k] ||
rth->fl.iif != 0 ||
dst_metric_locked(&rth->u.dst, RTAX_MTU) ||
!net_eq(dev_net(rth->u.dst.dev), net) ||
rth->rt_genid != atomic_read(&rt_genid))
continue;

if (new_mtu < 68 || new_mtu >= old_mtu) {

/* BSD 4.2 compatibility hack :-( */
Expand All @@ -1483,8 +1489,8 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
est_mtu = mtu;
}
}
rcu_read_unlock();
}
rcu_read_unlock();
}
return est_mtu ? : new_mtu;
}
Expand Down

0 comments on commit 0010e46

Please sign in to comment.