Hi All, So I'm a little unclear as to what to do here moving forward..
Do we all agree at least that there should be some function in DPDK in order to set the link state for KNI interfaces? I'm a strong yes on this point. I don't think that every KNI user should have to implement something like this themselves if we can provide a simple interface to do it. It seems like a natural extension of the KNI functionality IMHO. If so, should we use a new ioctl as in my patch, or just use the "write to /sys.../carrier" method as shown below? I'm kind of ambivalent about this point. The ioctl method has two minor advantages to my mind: 1) It's already done :) 2) You can set the link speed and duplex as well and get a pretty message in the syslog when the link status changes: [ 2100.016079] rte_kni: adax0 NIC Link is Up 10000 Mbps Full Duplex. [ 2100.016094] IPv6: ADDRCONF(NETDEV_CHANGE): adax0: link becomes ready [ 2262.532126] IPv6: ADDRCONF(NETDEV_UP): adax1: link is not ready [ 2263.432148] rte_kni: adax1 NIC Link is Up 10000 Mbps Full Duplex. [ 2263.432170] IPv6: ADDRCONF(NETDEV_CHANGE): adax1: link becomes ready On the other hand, the "write to /sys" method is a bit more simple and confines the changes to the user space library. If we're confident that the /sys ABI is stable and not going to be changed going forward it seems like a valid alternative. I'm willing to do it either way. I'll defer to the judgement of the community... thanks dan On Thu, Aug 30, 2018 at 6:49 AM, Igor Ryzhov <iryz...@nfware.com> wrote: > Hi Dan, > > We use KNI device exactly the same way you described – with IP addresses, > routing, etc. > And we also faced the same problem of having the actual link status in Linux > kernel. > > There is a special callback for link state management in net_device_ops for > soft-devices like KNI called ndo_change_carrier. > Current KNI driver implements it already, you just need to write to > /sys/class/net/<iface>/carrier to change link status. > > Right now we implement it on application side, but I think it'll be good to > have this in rte_kni API. > > Here is our implementation: > > static int > linux_set_carrier(const char *name, int status) > { > char path[64]; > const char *carrier = status ? "1" : "0"; > int fd, ret; > > sprintf(path, "/sys/devices/virtual/net/%s/carrier", name); > fd = open(path, O_WRONLY); > if (fd == -1) { > return -errno; > } > > ret = write(fd, carrier, 2); > if (ret == -1) { > close(fd); > return -errno; > } > > close(fd); > > return 0; > } > > Best regards, > Igor