Index: libnetutil/netutil.cc =================================================================== --- libnetutil/netutil.cc (revision 25615) +++ libnetutil/netutil.cc (working copy) @@ -1311,10 +1311,11 @@ return -1; } -/* Looks for an interface with the given name (iname), and returns the - corresponding interface_info if found. Will accept a match of - devname or devfullname. Returns NULL if none found */ -struct interface_info *getInterfaceByName(const char *iname) { +/* Looks for an interface with the given name (iname) and address + family type, and returns the corresponding interface_info if found. + Will accept a match of devname or devfullname. Returns NULL if + none found */ +struct interface_info *getInterfaceByName(const char *iname, u16 family) { struct interface_info *ifaces; int numifaces = 0; int ifnum; @@ -1322,8 +1323,9 @@ ifaces = getinterfaces(&numifaces, NULL, 0); for (ifnum = 0; ifnum < numifaces; ifnum++) { - if (strcmp(ifaces[ifnum].devfullname, iname) == 0 || - strcmp(ifaces[ifnum].devname, iname) == 0) + if ((strcmp(ifaces[ifnum].devfullname, iname) == 0 || + strcmp(ifaces[ifnum].devname, iname) == 0) && + ifaces[ifnum].addr.ss_family == family) return &ifaces[ifnum]; } @@ -2993,7 +2995,7 @@ struct interface_info *ii; ii = NULL; if (device != NULL && device[0] != '\0') { - ii = getInterfaceByName(device); + ii = getInterfaceByName(device, rtmsg->rtm_family); if (ii == NULL) netutil_fatal("Could not find interface %s which was specified by -e", device); } @@ -3012,7 +3014,7 @@ intf_index = *(int *) RTA_DATA(rtattr); rc = intf_name(intf_index, namebuf, sizeof(namebuf)); assert(rc != -1); - ii = getInterfaceByName(namebuf); + ii = getInterfaceByName(namebuf, rtmsg->rtm_family); if (ii == NULL) netutil_fatal("%s: can't find interface \"%s\"", __func__, namebuf); } else if (rtattr->rta_type == RTA_PREFSRC && rnfo->srcaddr.ss_family == AF_UNSPEC) { @@ -3108,7 +3110,7 @@ } if (device!=NULL && device[0]!='\0'){ - iface = getInterfaceByName(device); + iface = getInterfaceByName(device, dst->ss_family); if (!iface) netutil_fatal("Could not find interface %s which was specified by -e", device); } else { Index: libnetutil/netutil.h =================================================================== --- libnetutil/netutil.h (revision 25615) +++ libnetutil/netutil.h (working copy) @@ -357,10 +357,11 @@ int numifaces; }; -/* Looks for an interface with the given name (iname), and returns the - corresponding interface_info if found. Will accept a match of - devname or devfullname. Returns NULL if none found */ -struct interface_info *getInterfaceByName(const char *iname); +/* Looks for an interface with the given name (iname) and address + family type, and returns the corresponding interface_info if found. + Will accept a match of devname or devfullname. Returns NULL if + none found */ +struct interface_info *getInterfaceByName(const char *iname, u16 family); /* Parse the system routing table, converting each route into a sys_route entry. Returns an array of sys_routes. numroutes is set Index: nse_dnet.cc =================================================================== --- nse_dnet.cc (revision 25615) +++ nse_dnet.cc (working copy) @@ -51,7 +51,8 @@ { char ipstr[INET6_ADDRSTRLEN]; struct addr src, bcast; - struct interface_info *ii = getInterfaceByName(luaL_checkstring(L, 1)); + struct interface_info *ii = getInterfaceByName(luaL_checkstring(L, 1), + o.af()); if (ii == NULL) { lua_pushnil(L); @@ -155,7 +156,7 @@ { nse_dnet_udata *udata = (nse_dnet_udata *) luaL_checkudata(L, 1, DNET_METATABLE); const char *interface_name = luaL_checkstring(L, 2); - struct interface_info *ii = getInterfaceByName(interface_name); + struct interface_info *ii = getInterfaceByName(interface_name, o.af()); if (ii == NULL || ii->device_type != devt_ethernet) return luaL_argerror(L, 2, "device is not valid ethernet interface");