From: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
herbert-F6s6mLieUQo7FNHlEwC/lvQIK84fMopw@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
shlomop-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] IPoIB: Stop lying about hard_header_len and use skb->cb to stash LL addresses
Date: Tue, 7 Feb 2012 16:51:21 -0800 [thread overview]
Message-ID: <1328662281-16256-1-git-send-email-roland@kernel.org> (raw)
In-Reply-To: <CAG4TOxP2iEgT64L8vAR6P139U-HyHSxU8gdWw+cLsDwWSGkrwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
From: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Commit a0417fa3a18a ("net: Make qdisc_skb_cb upper size bound
explicit.") made it possible for a netdev driver to use skb->cb
between its header_ops.create method and its .ndo_start_xmit
method. Use this in ipoib_hard_header() to stash away the LL address
(GID + QPN), instead of the "ipoib_pseudoheader" hack. This allows
IPoIB to stop lying about its hard_header_len, which will let us fix
the L2 check for GRO.
Signed-off-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
---
OK, this works for me. Definitely looks cleaner and also looks
obvious enough that it's probably even correct.
drivers/infiniband/ulp/ipoib/ipoib.h | 6 ++-
drivers/infiniband/ulp/ipoib/ipoib_main.c | 55 ++++++++---------------
drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 10 +----
3 files changed, 24 insertions(+), 47 deletions(-)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index b3cc1e0..86df632 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -44,6 +44,7 @@
#include <linux/mutex.h>
#include <net/neighbour.h>
+#include <net/sch_generic.h>
#include <linux/atomic.h>
@@ -117,8 +118,9 @@ struct ipoib_header {
u16 reserved;
};
-struct ipoib_pseudoheader {
- u8 hwaddr[INFINIBAND_ALEN];
+struct ipoib_cb {
+ struct qdisc_skb_cb qdisc_cb;
+ u8 hwaddr[INFINIBAND_ALEN];
};
/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 3514ca0..3974c29 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -653,7 +653,7 @@ static void ipoib_path_lookup(struct sk_buff *skb, struct neighbour *n, struct n
}
static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
- struct ipoib_pseudoheader *phdr)
+ struct ipoib_cb *cb)
{
struct ipoib_dev_priv *priv = netdev_priv(dev);
struct ipoib_path *path;
@@ -661,17 +661,15 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
spin_lock_irqsave(&priv->lock, flags);
- path = __path_find(dev, phdr->hwaddr + 4);
+ path = __path_find(dev, cb->hwaddr + 4);
if (!path || !path->valid) {
int new_path = 0;
if (!path) {
- path = path_rec_create(dev, phdr->hwaddr + 4);
+ path = path_rec_create(dev, cb->hwaddr + 4);
new_path = 1;
}
if (path) {
- /* put pseudoheader back on for next time */
- skb_push(skb, sizeof *phdr);
__skb_queue_tail(&path->queue, skb);
if (!path->query && path_rec_start(dev, path)) {
@@ -695,12 +693,10 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
be16_to_cpu(path->pathrec.dlid));
spin_unlock_irqrestore(&priv->lock, flags);
- ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
+ ipoib_send(dev, skb, path->ah, IPOIB_QPN(cb->hwaddr));
return;
} else if ((path->query || !path_rec_start(dev, path)) &&
skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
- /* put pseudoheader back on for next time */
- skb_push(skb, sizeof *phdr);
__skb_queue_tail(&path->queue, skb);
} else {
++dev->stats.tx_dropped;
@@ -774,16 +770,14 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
dev_kfree_skb_any(skb);
}
} else {
- struct ipoib_pseudoheader *phdr =
- (struct ipoib_pseudoheader *) skb->data;
- skb_pull(skb, sizeof *phdr);
+ struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb;
- if (phdr->hwaddr[4] == 0xff) {
+ if (cb->hwaddr[4] == 0xff) {
/* Add in the P_Key for multicast*/
- phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff;
- phdr->hwaddr[9] = priv->pkey & 0xff;
+ cb->hwaddr[8] = (priv->pkey >> 8) & 0xff;
+ cb->hwaddr[9] = priv->pkey & 0xff;
- ipoib_mcast_send(dev, phdr->hwaddr + 4, skb);
+ ipoib_mcast_send(dev, cb->hwaddr + 4, skb);
} else {
/* unicast GID -- should be ARP or RARP reply */
@@ -792,14 +786,14 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x %pI6\n",
skb_dst(skb) ? "neigh" : "dst",
be16_to_cpup((__be16 *) skb->data),
- IPOIB_QPN(phdr->hwaddr),
- phdr->hwaddr + 4);
+ IPOIB_QPN(cb->hwaddr),
+ cb->hwaddr + 4);
dev_kfree_skb_any(skb);
++dev->stats.tx_dropped;
goto unlock;
}
- unicast_arp_send(skb, dev, phdr);
+ unicast_arp_send(skb, dev, cb);
}
}
unlock:
@@ -825,8 +819,6 @@ static int ipoib_hard_header(struct sk_buff *skb,
const void *daddr, const void *saddr, unsigned len)
{
struct ipoib_header *header;
- struct dst_entry *dst;
- struct neighbour *n;
header = (struct ipoib_header *) skb_push(skb, sizeof *header);
@@ -834,18 +826,13 @@ static int ipoib_hard_header(struct sk_buff *skb,
header->reserved = 0;
/*
- * If we don't have a neighbour structure, stuff the
- * destination address onto the front of the skb so we can
- * figure out where to send the packet later.
+ * If we don't have a dst_entry structure, stuff the
+ * destination address into skb->cb so we can figure out where
+ * to send the packet later.
*/
- dst = skb_dst(skb);
- n = NULL;
- if (dst)
- n = dst_get_neighbour_noref_raw(dst);
- if ((!dst || !n) && daddr) {
- struct ipoib_pseudoheader *phdr =
- (struct ipoib_pseudoheader *) skb_push(skb, sizeof *phdr);
- memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN);
+ if (!skb_dst(skb)) {
+ struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb;
+ memcpy(cb->hwaddr, daddr, INFINIBAND_ALEN);
}
return 0;
@@ -1021,11 +1008,7 @@ static void ipoib_setup(struct net_device *dev)
dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
- /*
- * We add in INFINIBAND_ALEN to allow for the destination
- * address "pseudoheader" for skbs without neighbour struct.
- */
- dev->hard_header_len = IPOIB_ENCAP_LEN + INFINIBAND_ALEN;
+ dev->hard_header_len = IPOIB_ENCAP_LEN;
dev->addr_len = INFINIBAND_ALEN;
dev->type = ARPHRD_INFINIBAND;
dev->tx_queue_len = ipoib_sendq_size * 2;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index f7ff9dd..20ebc6f 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -262,21 +262,13 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
netif_tx_lock_bh(dev);
while (!skb_queue_empty(&mcast->pkt_queue)) {
struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue);
- struct dst_entry *dst = skb_dst(skb);
- struct neighbour *n = NULL;
netif_tx_unlock_bh(dev);
skb->dev = dev;
- if (dst)
- n = dst_get_neighbour_noref_raw(dst);
- if (!dst || !n) {
- /* put pseudoheader back on for next time */
- skb_push(skb, sizeof (struct ipoib_pseudoheader));
- }
-
if (dev_queue_xmit(skb))
ipoib_warn(priv, "dev_queue_xmit failed to requeue packet\n");
+
netif_tx_lock_bh(dev);
}
netif_tx_unlock_bh(dev);
--
1.7.9
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-02-08 0:51 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <alpine.LRH.2.00.1201261624540.30384@ogerlitz.voltaire.com>
[not found] ` <alpine.LRH.2.00.1201261642340.31408@ogerlitz.voltaire.com>
[not found] ` <alpine.LRH.2.00.1201261642340.31408-VYr5/9ddeaGSIdy2EShu12Xnswh1EIUO@public.gmane.org>
2012-01-30 4:36 ` [PATCH 2/2] IB/ipoib: fix GRO merge failure for IPoIB originated TCP streams Roland Dreier
[not found] ` <CAL1RGDUm8ROxFFMa+D1ZD5jF+cK+kV8aEVzspgnZFNXeuai+fA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-30 7:44 ` Shlomo Pongratz
[not found] ` <36F7E4A28C18BE4DB7C86058E7B607240BE9687A-SlGPd/IId7auSA5JZHE7gA@public.gmane.org>
2012-01-30 18:11 ` Roland Dreier
[not found] ` <CAL1RGDXjjQ-PhCv-9WJX45NuovC9XiS=_7507OsyvLW_gBaJ5g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-30 18:16 ` Or Gerlitz
[not found] ` <CAJZOPZLhgDysSASyMLNpOrmGzEyfyHAQjGLVei6ZNSFfb7TM1w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-30 19:00 ` Roland Dreier
2012-01-30 7:44 ` Or Gerlitz
[not found] ` <4F264A6C.3070706-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-01-30 8:04 ` Eric Dumazet
2012-01-30 8:11 ` Or Gerlitz
2012-01-30 8:18 ` Herbert Xu
[not found] ` <20120130081849.GA7848-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2012-01-30 8:53 ` Eric Dumazet
2012-01-30 8:57 ` Herbert Xu
[not found] ` <20120130085742.GA8262-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2012-01-30 16:43 ` David Miller
2012-02-01 8:23 ` Or Gerlitz
[not found] ` <CAJZOPZJb1HvcS0XXKLvoDuoi1EfYTY-awwY2g0aHWoS=4qmdyQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 8:38 ` Herbert Xu
[not found] ` <20120201083837.GA7081-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2012-02-01 9:43 ` Or Gerlitz
2012-02-01 14:07 ` Eric Dumazet
2012-02-02 14:01 ` Or Gerlitz
[not found] ` <4F2A974B.209-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-02-02 14:38 ` Eric Dumazet
2012-02-02 14:44 ` Eric Dumazet
2012-02-02 21:42 ` Or Gerlitz
2012-02-02 15:43 ` Or Gerlitz
2012-01-30 8:25 ` Michał Mirosław
2012-02-02 21:58 ` Or Gerlitz
[not found] ` <alpine.LRH.2.00.1202022352560.30300-VYr5/9ddeaGSIdy2EShu12Xnswh1EIUO@public.gmane.org>
2012-02-03 7:18 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A823733349A5D2-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2012-02-03 9:00 ` Eric Dumazet
2012-02-03 20:24 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A823733349A6C9-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2012-02-06 15:05 ` Or Gerlitz
[not found] ` <4F2FEC36.6090800-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-02-06 15:21 ` Eric Dumazet
2012-02-06 15:22 ` Or Gerlitz
[not found] ` <4F2FF050.7040400-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-02-06 16:27 ` [PATCH net-next] gro: introduce gro_mac_header_len Eric Dumazet
2012-02-06 16:31 ` David Miller
[not found] ` <20120206.113145.1284864994961472499.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-06 16:44 ` Or Gerlitz
[not found] ` <4F300353.2080705-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-02-06 17:00 ` David Miller
2012-02-06 16:47 ` [PATCH net-next V2] " Eric Dumazet
2012-02-06 16:58 ` David Miller
2012-02-06 17:07 ` Eric Dumazet
2012-02-06 17:11 ` Or Gerlitz
[not found] ` <4F3009AE.2090605-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-02-06 17:19 ` Eric Dumazet
[not found] ` <20120206.115859.1384761795375582044.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-06 17:09 ` Or Gerlitz
2012-02-06 17:23 ` Roland Dreier
[not found] ` <CAG4TOxOBCbEEOtP62ZM1R3-6umebdbJFkK0bnjphLCZOgHzt1g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-06 19:12 ` David Miller
[not found] ` <20120206.141223.332863167187002998.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-06 19:23 ` Roland Dreier
[not found] ` <CAG4TOxNgJ3=AFuA==Km815YzW8eQ7nD_UAzkXLSXcAyaCAAvPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-06 19:32 ` David Miller
[not found] ` <20120206.143230.1415707004934341114.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-06 19:51 ` David Miller
[not found] ` <20120206.145148.558736903670696169.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-06 19:56 ` David Miller
[not found] ` <20120206.145652.1575591691467905094.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-06 20:01 ` Roland Dreier
[not found] ` <CAG4TOxNcB8+SP3f0WhZG1GZ481s+=7pVRv91vzAbwDzUZD8g_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-06 20:15 ` David Miller
[not found] ` <20120206.151509.1959432192519622134.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-07 19:51 ` Roland Dreier
2012-02-07 20:33 ` David Miller
[not found] ` <20120207.153325.1941809701255235550.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-07 20:34 ` Roland Dreier
[not found] ` <CAG4TOxP2iEgT64L8vAR6P139U-HyHSxU8gdWw+cLsDwWSGkrwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-08 0:51 ` Roland Dreier [this message]
2012-02-08 7:29 ` [PATCH] IPoIB: Stop lying about hard_header_len and use skb->cb to stash LL addresses Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373374C1C26-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2012-02-08 7:50 ` Eric Dumazet
2012-02-08 14:28 ` Or Gerlitz
2012-02-08 20:50 ` David Miller
2012-02-06 19:59 ` [PATCH net-next V2] gro: introduce gro_mac_header_len Roland Dreier
2012-02-08 18:51 ` [PATCH net-next] gro: more generic L2 header check Eric Dumazet
2012-02-08 20:50 ` David Miller
[not found] ` <20120208.155027.599792363539233740.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-08 21:08 ` Or Gerlitz
[not found] ` <CAJZOPZL_zEbNwUfVOmQeODny7HDf24gOc1HStfBxim_UtD-kvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-08 21:31 ` David Miller
[not found] ` <20120208.163159.2229331610142060560.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-08 21:49 ` Or Gerlitz
[not found] ` <CAJZOPZLLteDbm0prTN3-npubtFun=kO2DYT7ea=E-HyJ84gaiA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-08 23:09 ` David Miller
[not found] ` <20120208.180917.586628615268005115.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-08 23:20 ` Or Gerlitz
[not found] ` <CAJZOPZ+SyGsDpnK89wNWtBn4Jdzc2tg1diKjbHSv=n75XiG+ug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-08 23:26 ` David Miller
[not found] ` <20120208.182629.1816927738607872730.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-09 10:46 ` Or Gerlitz
[not found] ` <4F33A3FC.1050205-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-02-09 18:52 ` David Miller
[not found] ` <20120209.135235.957414875716615693.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-09 20:04 ` Or Gerlitz
2012-02-09 20:29 ` David Miller
[not found] ` <20120209.152943.1123862542883793404.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-09 22:18 ` Or Gerlitz
[not found] ` <CAJZOPZKUG-tT+Zd=1EiLhgRxg4VEDrisBJQ99XtARMvK68UWfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-09 22:28 ` David Miller
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=1328662281-16256-1-git-send-email-roland@kernel.org \
--to=roland-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=herbert-F6s6mLieUQo7FNHlEwC/lvQIK84fMopw@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=shlomop-VPRAkNaXOzVWk0Htik3J/w@public.gmane.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).