From: Paul Blakey <pa...@mellanox.com> We want to use this later in the HW offloading implementation which we currently also support Linux only.
Signed-off-by: Paul Blakey <pa...@mellanox.com> Reviewed-by: Roi Dayan <r...@mellanox.com> --- lib/netdev-linux.c | 7 +++---- lib/netdev-linux.h | 2 ++ lib/netdev-vport.c | 27 +++++++++++++++++---------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 124d2c3..a48c6d9 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -531,7 +531,6 @@ static int set_flags(const char *, unsigned int flags); static int update_flags(struct netdev_linux *netdev, enum netdev_flags off, enum netdev_flags on, enum netdev_flags *old_flagsp) OVS_REQUIRES(netdev->mutex); -static int do_get_ifindex(const char *netdev_name); static int get_ifindex(const struct netdev *, int *ifindexp); static int do_set_addr(struct netdev *netdev, int ioctl_nr, const char *ioctl_name, @@ -5374,8 +5373,8 @@ set_flags(const char *name, unsigned int flags) return af_inet_ifreq_ioctl(name, &ifr, SIOCSIFFLAGS, "SIOCSIFFLAGS"); } -static int -do_get_ifindex(const char *netdev_name) +int +linux_get_ifindex(const char *netdev_name) { struct ifreq ifr; int error; @@ -5398,7 +5397,7 @@ get_ifindex(const struct netdev *netdev_, int *ifindexp) struct netdev_linux *netdev = netdev_linux_cast(netdev_); if (!(netdev->cache_valid & VALID_IFINDEX)) { - int ifindex = do_get_ifindex(netdev_get_name(netdev_)); + int ifindex = linux_get_ifindex(netdev_get_name(netdev_)); if (ifindex < 0) { netdev->get_ifindex_error = -ifindex; diff --git a/lib/netdev-linux.h b/lib/netdev-linux.h index d944691..880f864 100644 --- a/lib/netdev-linux.h +++ b/lib/netdev-linux.h @@ -27,6 +27,7 @@ struct netdev; int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag, const char *flag_name, bool enable); +int linux_get_ifindex(const char *netdev_name); #define LINUX_FLOW_OFFLOAD_API \ netdev_tc_flow_flush, \ @@ -37,4 +38,5 @@ int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag, netdev_tc_flow_get, \ netdev_tc_flow_del, \ netdev_tc_init_flow_api + #endif /* netdev-linux.h */ diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 8cb03e6..befa4e4 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -45,6 +45,7 @@ #include "unaligned.h" #include "unixctl.h" #include "openvswitch/vlog.h" +#include "netdev-linux.h" VLOG_DEFINE_THIS_MODULE(netdev_vport); @@ -783,7 +784,8 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats) #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \ GET_TUNNEL_CONFIG, GET_STATUS, \ BUILD_HEADER, \ - PUSH_HEADER, POP_HEADER) \ + PUSH_HEADER, POP_HEADER, \ + GET_IFINDEX) \ NULL, \ netdev_vport_run, \ netdev_vport_wait, \ @@ -808,7 +810,7 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats) netdev_vport_get_etheraddr, \ NULL, /* get_mtu */ \ NULL, /* set_mtu */ \ - NULL, /* get_ifindex */ \ + GET_IFINDEX, \ NULL, /* get_carrier */ \ NULL, /* get_carrier_resets */ \ NULL, /* get_miimon */ \ @@ -859,14 +861,16 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats) NULL, /* init_flow_api */ -#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER) \ +#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER, \ + GET_IFINDEX) \ { DPIF_PORT, \ { NAME, false, \ VPORT_FUNCTIONS(get_tunnel_config, \ set_tunnel_config, \ get_netdev_tunnel_config, \ tunnel_get_status, \ - BUILD_HEADER, PUSH_HEADER, POP_HEADER) }} + BUILD_HEADER, PUSH_HEADER, POP_HEADER, \ + GET_IFINDEX) }} void netdev_vport_tunnel_register(void) @@ -876,15 +880,18 @@ netdev_vport_tunnel_register(void) static const struct vport_class vport_classes[] = { TUNNEL_CLASS("geneve", "genev_sys", netdev_geneve_build_header, netdev_tnl_push_udp_header, - netdev_geneve_pop_header), + netdev_geneve_pop_header, + NULL), TUNNEL_CLASS("gre", "gre_sys", netdev_gre_build_header, netdev_gre_push_header, - netdev_gre_pop_header), + netdev_gre_pop_header, + NULL), TUNNEL_CLASS("vxlan", "vxlan_sys", netdev_vxlan_build_header, netdev_tnl_push_udp_header, - netdev_vxlan_pop_header), - TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL), - TUNNEL_CLASS("stt", "stt_sys", NULL, NULL, NULL), + netdev_vxlan_pop_header, + NETDEV_VPORT_GET_IFINDEX), + TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL, NULL), + TUNNEL_CLASS("stt", "stt_sys", NULL, NULL, NULL, NULL), }; static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; @@ -911,6 +918,6 @@ netdev_vport_patch_register(void) VPORT_FUNCTIONS(get_patch_config, set_patch_config, NULL, - NULL, NULL, NULL, NULL) }}; + NULL, NULL, NULL, NULL, NULL) }}; netdev_register_provider(&patch_class.netdev_class); } -- 2.7.4 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev