From: Roland Dreier <roland@topspin.com>
To: davem@davemloft.net
Cc: netdev@oss.sgi.com, openib-general@openib.org, ipoverib@ietf.org
Subject: Re: [PATCH] IPv6: Add correct padding to IPoIB link addr option
Date: Tue, 18 Jan 2005 09:49:16 -0800 [thread overview]
Message-ID: <524qheeig3.fsf@topspin.com> (raw)
In-Reply-To: <528y6qej5w.fsf@topspin.com> (Roland Dreier's message of "Tue, 18 Jan 2005 09:33:47 -0800")
Sorry, somehow I left out the description of the patch saying why you
might want to apply it....
Anand Parthasarathy pointed out that draft-ietf-ipoib-ip-over-infiniband-09.txt says:
[DISC] specifies the length of source/target option in
number of 8-octets as indicated by a length of '3' above.
Since the IPoIB link-layer address is only 20-octet long,
two octets of zero MUST be prepended to fill the total
option length of 24 octets.
The current Linux neighbour discovery code puts the padding after the
link address. This patch fixes up ndisc.c to put the padding in the
correct place by adding a general ndisc_addr_option_pad() function
(which could be used in the future if someone ever implements RFC 3831
IPv6-over-FC or some other encapsulation that requires padding).
Signed-off-by: Roland Dreier <roland@topspin.com>
--- linux-bk.orig/net/ipv6/ndisc.c 2005-01-12 13:27:52.000000000 -0800
+++ linux-bk/net/ipv6/ndisc.c 2005-01-14 21:20:55.736745091 -0800
@@ -169,12 +169,33 @@
#define NDISC_OPT_SPACE(len) (((len)+2+7)&~7)
-static u8 *ndisc_fill_option(u8 *opt, int type, void *data, int data_len)
+/*
+ * Return the padding between the option length and the start of the
+ * link addr. Currently only IP-over-InfiniBand needs this, although
+ * if RFC 3831 IPv6-over-Fibre Channel is ever implemented it may
+ * also need a pad of 2.
+ */
+static int ndisc_addr_option_pad(unsigned short type)
+{
+ switch (type) {
+ case ARPHRD_INFINIBAND: return 2;
+ default: return 0;
+ }
+}
+
+static u8 *ndisc_fill_addr_option(u8 *opt, int type, void *data, int data_len,
+ unsigned short addr_type)
{
int space = NDISC_OPT_SPACE(data_len);
+ int pad = ndisc_addr_option_pad(addr_type);
opt[0] = type;
opt[1] = space>>3;
+
+ memset(opt + 2, 0, pad);
+ opt += pad;
+ space -= pad;
+
memcpy(opt+2, data, data_len);
data_len += 2;
opt += data_len;
@@ -453,7 +474,8 @@
ipv6_addr_copy(&msg->target, solicited_addr);
if (inc_opt)
- ndisc_fill_option(msg->opt, ND_OPT_TARGET_LL_ADDR, dev->dev_addr, dev->addr_len);
+ ndisc_fill_addr_option(msg->opt, ND_OPT_TARGET_LL_ADDR, dev->dev_addr,
+ dev->addr_len, dev->type);
/* checksum */
msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, len,
@@ -536,7 +558,8 @@
ipv6_addr_copy(&msg->target, solicit);
if (send_llinfo)
- ndisc_fill_option(msg->opt, ND_OPT_SOURCE_LL_ADDR, dev->dev_addr, dev->addr_len);
+ ndisc_fill_addr_option(msg->opt, ND_OPT_SOURCE_LL_ADDR, dev->dev_addr,
+ dev->addr_len, dev->type);
/* checksum */
msg->icmph.icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr,
@@ -610,7 +633,8 @@
opt = (u8*) (hdr + 1);
if (dev->addr_len)
- ndisc_fill_option(opt, ND_OPT_SOURCE_LL_ADDR, dev->dev_addr, dev->addr_len);
+ ndisc_fill_addr_option(opt, ND_OPT_SOURCE_LL_ADDR, dev->dev_addr,
+ dev->addr_len, dev->type);
/* checksum */
hdr->icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr, daddr, len,
@@ -717,7 +741,8 @@
}
if (ndopts.nd_opts_src_lladdr) {
- lladdr = (u8*)(ndopts.nd_opts_src_lladdr + 1);
+ lladdr = (u8*)(ndopts.nd_opts_src_lladdr + 1) +
+ ndisc_addr_option_pad(dev->type);
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len)) {
ND_PRINTK2(KERN_WARNING
@@ -874,7 +899,8 @@
return;
}
if (ndopts.nd_opts_tgt_lladdr) {
- lladdr = (u8*)(ndopts.nd_opts_tgt_lladdr + 1);
+ lladdr = (u8*)(ndopts.nd_opts_tgt_lladdr + 1) +
+ ndisc_addr_option_pad(dev->type);
lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len)) {
ND_PRINTK2(KERN_WARNING
@@ -964,7 +990,8 @@
}
if (ndopts.nd_opts_src_lladdr) {
- lladdr = (u8 *)(ndopts.nd_opts_src_lladdr + 1);
+ lladdr = (u8 *)(ndopts.nd_opts_src_lladdr + 1) +
+ ndisc_addr_option_pad(skb->dev->type);
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len))
goto out;
@@ -1130,7 +1157,8 @@
u8 *lladdr = NULL;
int lladdrlen;
if (ndopts.nd_opts_src_lladdr) {
- lladdr = (u8*)((ndopts.nd_opts_src_lladdr)+1);
+ lladdr = (u8*)((ndopts.nd_opts_src_lladdr)+1) +
+ ndisc_addr_option_pad(skb->dev->type);
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len)) {
ND_PRINTK2(KERN_WARNING
@@ -1250,7 +1278,8 @@
return;
}
if (ndopts.nd_opts_tgt_lladdr) {
- lladdr = (u8*)(ndopts.nd_opts_tgt_lladdr + 1);
+ lladdr = (u8*)(ndopts.nd_opts_tgt_lladdr + 1) +
+ ndisc_addr_option_pad(skb->dev->type);
lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len)) {
ND_PRINTK2(KERN_WARNING
@@ -1379,7 +1408,8 @@
*/
if (dev->addr_len)
- opt = ndisc_fill_option(opt, ND_OPT_TARGET_LL_ADDR, neigh->ha, dev->addr_len);
+ opt = ndisc_fill_addr_option(opt, ND_OPT_TARGET_LL_ADDR, neigh->ha,
+ dev->addr_len, dev->type);
/*
* build redirect option and copy skb over to the new packet.
next prev parent reply other threads:[~2005-01-18 17:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-18 17:33 [PATCH] IPv6: Add correct padding to IPoIB link addr option Roland Dreier
2005-01-18 17:49 ` Roland Dreier [this message]
2005-01-18 21:27 ` David S. Miller
2005-01-19 0:20 ` [Ipoverib] " YOSHIFUJI Hideaki / 吉藤英明
2005-01-19 7:49 ` Krishna Kumar
2005-01-19 8:18 ` Vivek Kashyap
2005-01-19 9:02 ` YOSHIFUJI Hideaki / 吉藤英明
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=524qheeig3.fsf@topspin.com \
--to=roland@topspin.com \
--cc=davem@davemloft.net \
--cc=ipoverib@ietf.org \
--cc=netdev@oss.sgi.com \
--cc=openib-general@openib.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).