Message ID | 20180308005414.28692-1-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
On Wed, Mar 07, 2018 at 04:54:14PM -0800, Bart Van Assche wrote: > Split IPv6 addresses at the colon that separates the IPv6 address > and the port number instead of at a colon in the middle of the IPv6 > address. That isn't how IPv6 addresses are supposed to be represented.. A IPv6 with a port should be enclosed in [] eg [2001::123]:12 Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 2018-03-07 at 20:10 -0700, Jason Gunthorpe wrote: > On Wed, Mar 07, 2018 at 04:54:14PM -0800, Bart Van Assche wrote: > > Split IPv6 addresses at the colon that separates the IPv6 address > > and the port number instead of at a colon in the middle of the IPv6 > > address. > > That isn't how IPv6 addresses are supposed to be represented.. > > A IPv6 with a port should be enclosed in [] eg > > [2001::123]:12 Hello Jason, The patch I posted fixes parsing of IPv6 addresses like the one in your example. Did I perhaps misunderstand something? Thanks, Bart.
On Thu, Mar 08, 2018 at 03:18:54AM +0000, Bart Van Assche wrote: > On Wed, 2018-03-07 at 20:10 -0700, Jason Gunthorpe wrote: > > On Wed, Mar 07, 2018 at 04:54:14PM -0800, Bart Van Assche wrote: > > > Split IPv6 addresses at the colon that separates the IPv6 address > > > and the port number instead of at a colon in the middle of the IPv6 > > > address. > > > > That isn't how IPv6 addresses are supposed to be represented.. > > > > A IPv6 with a port should be enclosed in [] eg > > > > [2001::123]:12 > > Hello Jason, > > The patch I posted fixes parsing of IPv6 addresses like the one in your > example. Did I perhaps misunderstand something? ?? I don't see any handling of [] in the code? Doesn't the code split the above into '[2001::123]' and '12' Then pass that to inet_pton_with_scope which will barf on the [] address? It is just very jarring to see code handling IPv6 addresses + port and not use the standard/expected [] notation. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 2018-03-07 at 20:28 -0700, Jason Gunthorpe wrote: > On Thu, Mar 08, 2018 at 03:18:54AM +0000, Bart Van Assche wrote: > > On Wed, 2018-03-07 at 20:10 -0700, Jason Gunthorpe wrote: > > > On Wed, Mar 07, 2018 at 04:54:14PM -0800, Bart Van Assche wrote: > > > > Split IPv6 addresses at the colon that separates the IPv6 address > > > > and the port number instead of at a colon in the middle of the IPv6 > > > > address. > > > > > > That isn't how IPv6 addresses are supposed to be represented.. > > > > > > A IPv6 with a port should be enclosed in [] eg > > > > > > [2001::123]:12 > > > > Hello Jason, > > > > The patch I posted fixes parsing of IPv6 addresses like the one in your > > example. Did I perhaps misunderstand something? > > ?? I don't see any handling of [] in the code? > > Doesn't the code split the above into > > '[2001::123]' and '12' > > Then pass that to inet_pton_with_scope which will barf on the [] > address? > > It is just very jarring to see code handling IPv6 addresses + port and > not use the standard/expected [] notation. Hello Jason, What srp_parse_in() does with this patch applied is to split [2001::123]:12 into [2001::123] and 12. Without this patch the same address is split into [2001 and :123]:12, which is wrong. Bart.
On Thu, Mar 08, 2018 at 03:49:53AM +0000, Bart Van Assche wrote: > On Wed, 2018-03-07 at 20:28 -0700, Jason Gunthorpe wrote: > > On Thu, Mar 08, 2018 at 03:18:54AM +0000, Bart Van Assche wrote: > > > On Wed, 2018-03-07 at 20:10 -0700, Jason Gunthorpe wrote: > > > > On Wed, Mar 07, 2018 at 04:54:14PM -0800, Bart Van Assche wrote: > > > > > Split IPv6 addresses at the colon that separates the IPv6 address > > > > > and the port number instead of at a colon in the middle of the IPv6 > > > > > address. > > > > > > > > That isn't how IPv6 addresses are supposed to be represented.. > > > > > > > > A IPv6 with a port should be enclosed in [] eg > > > > > > > > [2001::123]:12 > > > > > > Hello Jason, > > > > > > The patch I posted fixes parsing of IPv6 addresses like the one in your > > > example. Did I perhaps misunderstand something? > > > > ?? I don't see any handling of [] in the code? > > > > Doesn't the code split the above into > > > > '[2001::123]' and '12' > > > > Then pass that to inet_pton_with_scope which will barf on the [] > > address? > > > > It is just very jarring to see code handling IPv6 addresses + port and > > not use the standard/expected [] notation. > > Hello Jason, > > What srp_parse_in() does with this patch applied is to split [2001::123]:12 > into [2001::123] and 12. Without this patch the same address is split into > [2001 and :123]:12, which is wrong. Hm, Ok. I didn't find the handling of the [] but I'm sure you have tested it. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
T24gTW9uLCAyMDE4LTAzLTEyIGF0IDExOjU0IC0wNjAwLCBKYXNvbiBHdW50aG9ycGUgd3JvdGU6 DQo+IEhtLCBPay4gSSBkaWRuJ3QgZmluZCB0aGUgaGFuZGxpbmcgb2YgdGhlIFtdIGJ1dCBJJ20g c3VyZSB5b3UgaGF2ZQ0KPiB0ZXN0ZWQgaXQuDQoNCkhlbGxvIEphc29uLA0KDQpUaGlzIHBhdGNo IGhhcyBiZWVuIHRlc3RlZCBhbmQgaXMgd2hhdCBJIGNhbWUgdXAgd2l0aCB3aGlsZSB0ZXN0aW5n IElQdjYNCnN1cHBvcnQgaW4gdGhlIFNSUCBpbml0aWF0b3IuIEJ1dCBJIGNhbid0IGZpbmQgdGhl IGhhbmRsaW5nIG9mIHRoZSBzcXVhcmUNCmJyYWNrZXRzIG15c2VsZiBpbiBpbmV0Nl9wdG9uKCkg c28gSSB3aWxsIGhhdmUgYW5vdGhlciBsb29rIGF0IHRoaXMuDQoNCkJhcnQuDQoNCg0K -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 9a5ea6251450..1fe24b82d851 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3418,12 +3418,15 @@ static int srp_parse_in(struct net *net, struct sockaddr_storage *sa, const char *addr_port_str) { char *addr = kstrdup(addr_port_str, GFP_KERNEL); - char *port_str = addr; + char *port_str; int ret; if (!addr) return -ENOMEM; - strsep(&port_str, ":"); + port_str = strrchr(addr, ':'); + if (!port_str) + return -EINVAL; + *port_str++ = '\0'; ret = inet_pton_with_scope(net, AF_UNSPEC, addr, port_str, sa); kfree(addr); return ret;
Split IPv6 addresses at the colon that separates the IPv6 address and the port number instead of at a colon in the middle of the IPv6 address. Fixes: 19f313438c77 ("IB/srp: Add RDMA/CM support") Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> --- drivers/infiniband/ulp/srp/ib_srp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)