From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/6] vxlan: minor output refactoring
Date: Tue, 09 Oct 2012 10:56:38 -0700 [thread overview]
Message-ID: <20121009175714.462171246@vyatta.com> (raw)
In-Reply-To: 20121009175637.048993312@vyatta.com
[-- Attachment #1: vxlan-dst.patch --]
[-- Type: text/plain, Size: 1722 bytes --]
Move code to find destination to a small function.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/vxlan.c 2012-10-09 10:34:57.000000000 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 10:48:56.546879617 -0700
@@ -621,6 +621,18 @@ 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;
+ struct vxlan_fdb *f;
+
+ if (is_multicast_ether_addr(eth->h_dest) ||
+ (f = vxlan_find_mac(vxlan, eth->h_dest)) == NULL)
+ return vxlan->gaddr;
+ else
+ return f->remote_ip;
+}
+
/* Transmit local packets over Vxlan
*
* Outer IP header inherits ECN and DF from inner header.
@@ -632,13 +644,11 @@ static netdev_tx_t vxlan_xmit(struct sk_
{
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 +656,16 @@ static netdev_tx_t vxlan_xmit(struct sk_
__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;
next prev parent reply other threads:[~2012-10-09 18:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 17:56 [PATCH 0/6] VXLAN fixes Stephen Hemminger
2012-10-09 17:56 ` Stephen Hemminger [this message]
2012-10-09 18:27 ` [PATCH 1/6] vxlan: minor output refactoring Joe Perches
2012-10-09 18:29 ` Stephen Hemminger
2012-10-10 8:08 ` David Laight
2012-10-09 17:56 ` [PATCH 2/6] vxlan: use ip_route_output Stephen Hemminger
2012-10-09 17:56 ` [PATCH 3/6] vxlan: associate with tunnel socket on xmit Stephen Hemminger
2012-10-09 17:56 ` [PATCH 4/6] VXLAN bases source UDP port based on flow to help the receiver to be able to load balance based on outer header flow Stephen Hemminger
2012-10-09 18:07 ` Stephen Hemminger
2012-10-09 18:14 ` David Miller
2012-10-09 18:38 ` Ben Hutchings
2012-10-09 17:56 ` [PATCH 5/6] vxlan: add additional headroom Stephen Hemminger
2012-10-09 17:56 ` [PATCH 6/6] vxlan: fix receive checksum handling Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121009175714.462171246@vyatta.com \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).