diff options
author | stephen hemminger <shemminger@vyatta.com> | 2012-10-09 20:35:46 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-10-10 22:41:21 -0400 |
commit | ef59febe3b2aa475bc2bf5b390db5e189f395710 (patch) | |
tree | 1db86b40a1067aaa20e0ce6b3c629fbc8af78b2d /drivers/net | |
parent | 2a5cf8016c745191605f312a7cd7bd22e9be94a5 (diff) | |
download | linux-ef59febe3b2aa475bc2bf5b390db5e189f395710.tar.bz2 |
vxlan: minor output refactoring
Move code to find destination to a small function.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/vxlan.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 8be9bf07bd39..92150c0cf4d9 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -621,6 +621,22 @@ static inline u8 vxlan_ecn_encap(u8 tos, return INET_ECN_encapsulate(tos, inner); } +static __be32 vxlan_find_dst(struct vxlan_dev *vxlan, struct sk_buff *skb) +{ + const struct ethhdr *eth = (struct ethhdr *) skb->data; + const struct vxlan_fdb *f; + + if (is_multicast_ether_addr(eth->h_dest)) + return vxlan->gaddr; + + f = vxlan_find_mac(vxlan, eth->h_dest); + if (f) + return f->remote_ip; + else + return vxlan->gaddr; + +} + /* Transmit local packets over Vxlan * * Outer IP header inherits ECN and DF from inner header. @@ -632,13 +648,11 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) { struct vxlan_dev *vxlan = netdev_priv(dev); struct rtable *rt; - const struct ethhdr *eth; const struct iphdr *old_iph; struct iphdr *iph; struct vxlanhdr *vxh; struct udphdr *uh; struct flowi4 fl4; - struct vxlan_fdb *f; unsigned int pkt_len = skb->len; u32 hash; __be32 dst; @@ -646,21 +660,16 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) __u8 tos, ttl; int err; + dst = vxlan_find_dst(vxlan, skb); + if (!dst) + goto drop; + /* Need space for new headers (invalidates iph ptr) */ if (skb_cow_head(skb, VXLAN_HEADROOM)) goto drop; - eth = (void *)skb->data; old_iph = ip_hdr(skb); - if (!is_multicast_ether_addr(eth->h_dest) && - (f = vxlan_find_mac(vxlan, eth->h_dest))) - dst = f->remote_ip; - else if (vxlan->gaddr) { - dst = vxlan->gaddr; - } else - goto drop; - ttl = vxlan->ttl; if (!ttl && IN_MULTICAST(ntohl(dst))) ttl = 1; |