Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 314721
b: refs/heads/master
c: a207a4b
h: refs/heads/master
i:
  314719: 88d4a56
v: v3
  • Loading branch information
David S. Miller committed Jun 29, 2012
1 parent 93e2eb9 commit 542754f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 58050fce3530939372e6c2f4b4beb76fcb4caa65
refs/heads/master: a207a4b2e8067cbc7f33924e7f2c0fa4ef43b459
34 changes: 21 additions & 13 deletions trunk/net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,36 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
struct net_device *dev = skb->dev;
struct in_device *in_dev;
struct fib_result res;
struct rtable *rt;
struct flowi4 fl4;
struct net *net;
int scope;

if (skb->pkt_type != PACKET_BROADCAST &&
skb->pkt_type != PACKET_MULTICAST)
rt = skb_rtable(skb);
if (!(rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)))
return ip_hdr(skb)->daddr;

in_dev = __in_dev_get_rcu(dev);
BUG_ON(!in_dev);
fl4.flowi4_oif = 0;
fl4.flowi4_iif = 0;
fl4.daddr = ip_hdr(skb)->saddr;
fl4.saddr = ip_hdr(skb)->daddr;
fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
fl4.flowi4_scope = RT_SCOPE_UNIVERSE;
fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0;

net = dev_net(dev);
if (!fib_lookup(net, &fl4, &res))
return FIB_RES_PREFSRC(net, res);
else
return inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);

scope = RT_SCOPE_UNIVERSE;
if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
fl4.flowi4_oif = 0;
fl4.flowi4_iif = net->loopback_dev->ifindex;
fl4.daddr = ip_hdr(skb)->saddr;
fl4.saddr = 0;
fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
fl4.flowi4_scope = scope;
fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0;
if (!fib_lookup(net, &fl4, &res))
return FIB_RES_PREFSRC(net, res);
} else {
scope = RT_SCOPE_LINK;
}

return inet_select_addr(dev, ip_hdr(skb)->saddr, scope);
}

/* Given (packet source, input interface) and optional (dst, oif, tos):
Expand Down

0 comments on commit 542754f

Please sign in to comment.