11/01/2018 10:00, Matan Azrad: > From: Stephen Hemminger, Wednesday, January 10, 2018 6:44 PM > > > From: Stephen Hemminger, Tuesday, January 9, 2018 8:51 PM > > > > On Tue, 9 Jan 2018 14:47:31 +0000 > > > > Matan Azrad <ma...@mellanox.com> wrote: > > > > > +static int > > > > > +vdev_netvsc_has_route(const char *name) { > > > > > + FILE *fp; > > > > > + int ret = 0; > > > > > + char route[NETVSC_MAX_ROUTE_LINE_SIZE]; > > > > > + char *netdev; > > > > > + > > > > > + fp = fopen("/proc/net/route", "r"); > > > > > + if (!fp) { > > > > > + rte_errno = errno; > > > > > + return 0; > > > > > + } > > > > > + while (fgets(route, NETVSC_MAX_ROUTE_LINE_SIZE, fp) != NULL) { > > > > > + netdev = strtok(route, "\t"); > > > > > + if (strcmp(netdev, name) == 0) { > > > > > + ret = 1; > > > > > + break; > > > > > + } > > > > > + /* Move file pointer to the next line. */ > > > > > + while (strchr(route, '\n') == NULL && > > > > > + fgets(route, NETVSC_MAX_ROUTE_LINE_SIZE, fp) != > > > > NULL) > > > > > + ; > > > > > + } > > > > > + fclose(fp); > > > > > + return ret; > > > > > +} > > > > > > > > In many ways /proc/net/route is legacy intervace. > > > > And system may have 1 M routes. > > > > > > > > Maybe there is faster way to do this with netlink by looking to see > > > > if there is an address associated with the interface. > > > > > > Actually this is control path, we don't care about performance very much. > > > But I can get other idea here, Do you have suggestion? > > > > > > Thanks! > > > > > > > Use netlink (or ioctl) to get interface address. > > If interface has an IPv4 or IPv6 (not link local), then skip it. > > As I a little bit investigated I found that IPv6 getting is problematic by > ioctl. > And using nelink for it, really doesn't worth the effort. > So, I suggest to keep this code simple as is in spite of the optional high > latency for this function, after all it is a control path.
No more comment? So we are OK with this solution for now? If we see real performance issue, I guess it can be fixed later.