Message ID | 1418050713-29694-2-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | New |
Headers | show |
Patch does not describe why the loop needed fixing, the message also does not indicate if it was an example, test or implementation change. On 8 December 2014 at 09:58, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > --- > platform/linux-generic/odp_packet_io.c | 58 > ++++++++-------------------------- > 1 file changed, 13 insertions(+), 45 deletions(-) > > diff --git a/platform/linux-generic/odp_packet_io.c > b/platform/linux-generic/odp_packet_io.c > index 833725e..4399ef9 100644 > --- a/platform/linux-generic/odp_packet_io.c > +++ b/platform/linux-generic/odp_packet_io.c > @@ -155,33 +155,6 @@ static int free_pktio_entry(odp_pktio_t id) > return 0; > } > > -static int find_loop_dev(char loop[IFNAMSIZ]) > -{ > - struct ifaddrs *ifap, *ifa; > - > - getifaddrs(&ifap); > - > - for (ifa = ifap; ifa; ifa = ifa->ifa_next) { > - if (ifa->ifa_addr && > - ifa->ifa_addr->sa_family == AF_INET) { > - if ((ifa->ifa_flags & (IFF_LOOPBACK | > - IFF_POINTOPOINT | > - IFF_NOARP)) || > - (!memcmp(ifa->ifa_name, "lxcbr", 5)) || > - (!memcmp(ifa->ifa_name, "wlan", 4)) || > - (!memcmp(ifa->ifa_name, "veth", 4)) || > - (!memcmp(ifa->ifa_name, "virbr", 5))) > - continue; > - memcpy(loop, ifa->ifa_name, IFNAMSIZ); > - freeifaddrs(ifap); > - return 0; > - } > - } > - > - freeifaddrs(ifap); > - return -1; > -} > - > odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) > { > odp_pktio_t id; > @@ -203,26 +176,21 @@ odp_pktio_t odp_pktio_open(const char *dev, > odp_buffer_pool_t pool) > */ > loop_hint = getenv("ODP_PKTIO_LOOPDEV"); > if (!strcmp(dev, "loop")) { > - if (loop_hint && (strlen(loop_hint) > 0)) { > - if (strlen(loop_hint) >= IFNAMSIZ) { > - ODP_ERR("pktio name %s is too big, limit > is %d bytes\n", > - loop_hint, IFNAMSIZ); > - return ODP_PKTIO_INVALID; > - } > + if (!loop_hint || (strlen(loop_hint) == 0)) { > + ODP_ERR("Set loop with ODP_PKTIO_LOOPDEV=ethX\n"); > + return ODP_PKTIO_INVALID; > + } > > - memset(loop, 0, IFNAMSIZ); > - memcpy(loop, loop_hint, strlen(loop_hint)); > - dev = loop; > - ODP_DBG("pktio using %s as loopback device\n", > loop_hint); > - } else { > - if (!find_loop_dev(loop)) { > - ODP_DBG("pktio rename loop to %s\n", loop); > - dev = loop; > - } else { > - ODP_DBG("pktio: No suitable netdev.\n"); > - return ODP_PKTIO_INVALID; > - } > + if (strlen(loop_hint) >= IFNAMSIZ) { > + ODP_ERR("pktio name %s is too big, limit is %d > bytes\n", > + loop_hint, IFNAMSIZ); > + return ODP_PKTIO_INVALID; > } > + > + memset(loop, 0, IFNAMSIZ); > + memcpy(loop, loop_hint, strlen(loop_hint)); > + dev = loop; > + ODP_DBG("pktio using %s as loopback device\n", loop_hint); > } > > id = alloc_lock_pktio_entry(); > -- > 1.8.5.1.163.gd7aced9 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 833725e..4399ef9 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -155,33 +155,6 @@ static int free_pktio_entry(odp_pktio_t id) return 0; } -static int find_loop_dev(char loop[IFNAMSIZ]) -{ - struct ifaddrs *ifap, *ifa; - - getifaddrs(&ifap); - - for (ifa = ifap; ifa; ifa = ifa->ifa_next) { - if (ifa->ifa_addr && - ifa->ifa_addr->sa_family == AF_INET) { - if ((ifa->ifa_flags & (IFF_LOOPBACK | - IFF_POINTOPOINT | - IFF_NOARP)) || - (!memcmp(ifa->ifa_name, "lxcbr", 5)) || - (!memcmp(ifa->ifa_name, "wlan", 4)) || - (!memcmp(ifa->ifa_name, "veth", 4)) || - (!memcmp(ifa->ifa_name, "virbr", 5))) - continue; - memcpy(loop, ifa->ifa_name, IFNAMSIZ); - freeifaddrs(ifap); - return 0; - } - } - - freeifaddrs(ifap); - return -1; -} - odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) { odp_pktio_t id; @@ -203,26 +176,21 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) */ loop_hint = getenv("ODP_PKTIO_LOOPDEV"); if (!strcmp(dev, "loop")) { - if (loop_hint && (strlen(loop_hint) > 0)) { - if (strlen(loop_hint) >= IFNAMSIZ) { - ODP_ERR("pktio name %s is too big, limit is %d bytes\n", - loop_hint, IFNAMSIZ); - return ODP_PKTIO_INVALID; - } + if (!loop_hint || (strlen(loop_hint) == 0)) { + ODP_ERR("Set loop with ODP_PKTIO_LOOPDEV=ethX\n"); + return ODP_PKTIO_INVALID; + } - memset(loop, 0, IFNAMSIZ); - memcpy(loop, loop_hint, strlen(loop_hint)); - dev = loop; - ODP_DBG("pktio using %s as loopback device\n", loop_hint); - } else { - if (!find_loop_dev(loop)) { - ODP_DBG("pktio rename loop to %s\n", loop); - dev = loop; - } else { - ODP_DBG("pktio: No suitable netdev.\n"); - return ODP_PKTIO_INVALID; - } + if (strlen(loop_hint) >= IFNAMSIZ) { + ODP_ERR("pktio name %s is too big, limit is %d bytes\n", + loop_hint, IFNAMSIZ); + return ODP_PKTIO_INVALID; } + + memset(loop, 0, IFNAMSIZ); + memcpy(loop, loop_hint, strlen(loop_hint)); + dev = loop; + ODP_DBG("pktio using %s as loopback device\n", loop_hint); } id = alloc_lock_pktio_entry();
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- platform/linux-generic/odp_packet_io.c | 58 ++++++++-------------------------- 1 file changed, 13 insertions(+), 45 deletions(-)