On Tue, Sep 24, 2019 at 1:03 AM Bart Van Assche <bvanassche@xxxxxxx> wrote: > > On 6/20/19 8:03 AM, Jack Wang wrote: > > +static int ibtrs_str_gid_to_sockaddr(const char *addr, size_t len, > > + short port, struct sockaddr_storage *dst) > > +{ > > + struct sockaddr_ib *dst_ib = (struct sockaddr_ib *)dst; > > + int ret; > > + > > + /* > > + * We can use some of the I6 functions since GID is a valid > > + * IPv6 address format > > + */ > > + ret = in6_pton(addr, len, dst_ib->sib_addr.sib_raw, '\0', NULL); > > + if (ret == 0) > > + return -EINVAL; > > + > > + dst_ib->sib_family = AF_IB; > > + /* > > + * Use the same TCP server port number as the IB service ID > > + * on the IB port space range > > + */ > > + dst_ib->sib_sid = cpu_to_be64(RDMA_IB_IP_PS_IB | port); > > + dst_ib->sib_sid_mask = cpu_to_be64(0xffffffffffffffffULL); > > + dst_ib->sib_pkey = cpu_to_be16(0xffff); > > + > > + return 0; > > +} > > + > > +/** > > + * ibtrs_str_to_sockaddr() - Convert ibtrs address string to sockaddr > > + * @addr String representation of an addr (IPv4, IPv6 or IB GID): > > + * - "ip:192.168.1.1" > > + * - "ip:fe80::200:5aee:feaa:20a2" > > + * - "gid:fe80::200:5aee:feaa:20a2" > > + * @len String address length > > + * @port Destination port > > + * @dst Destination sockaddr structure > > + * > > + * Returns 0 if conversion successful. Non-zero on error. > > + */ > > +static int ibtrs_str_to_sockaddr(const char *addr, size_t len, > > + short port, struct sockaddr_storage *dst) > > +{ > > + if (strncmp(addr, "gid:", 4) == 0) { > > + return ibtrs_str_gid_to_sockaddr(addr + 4, len - 4, port, dst); > > + } else if (strncmp(addr, "ip:", 3) == 0) { > > + char port_str[8]; > > + char *cpy; > > + int err; > > + > > + snprintf(port_str, sizeof(port_str), "%u", port); > > + cpy = kstrndup(addr + 3, len - 3, GFP_KERNEL); > > + err = cpy ? inet_pton_with_scope(&init_net, AF_UNSPEC, > > + cpy, port_str, dst) : -ENOMEM; > > + kfree(cpy); > > + > > + return err; > > + } > > + return -EPROTONOSUPPORT; > > +} > > A considerable amount of code is required to support the IB/CM. Does > supporting the IB/CM add any value? If that code would be left out, > would anything break? Is it really useful to support IB networks where > no IP address has been assigned to each IB port? We had quite some problems with ipoib in the past, especially neighbor discovery, from time to time we encountered some IP are not reachable from other hosts. That's why we want to have AF_IB support, which doesn't reply on IPoIB. Thanks, Jinpu