Skip to content

Commit

Permalink
netdev-offload-tc: Add checking when assigning flow api
Browse files Browse the repository at this point in the history
netdev_assign_flow_api will try to init the netdev,
if success, the netdev will use the offload api.
If we init the type of netdev is dpdk, using the tc offload
api (netdev_tc_init_flow_api, which may be called firstly.),
the err log always is showing up. This patch adds a additional
check, and can void the err log.

"failed adding ingress qdisc required for offloading: No such device"

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
xpu22 authored and ovsrobot committed Dec 23, 2019
1 parent 7efc698 commit f6d9490
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/netdev-linux.c
Expand Up @@ -3317,6 +3317,27 @@ const struct netdev_class netdev_afxdp_class = {
#endif


static bool
is_linux_class(const struct netdev_class *class)
{
if (class->destruct == netdev_linux_destruct) {
return true;
}
#ifdef HAVE_AF_XDP
if (class->destruct == netdev_afxdp_destruct) {
return true;
}
#endif

return false;
}

bool
netdev_linux_flow_api_supported(const struct netdev *netdev)
{
return is_linux_class(netdev->netdev_class);
}

#define CODEL_N_QUEUES 0x0000

/* In sufficiently new kernel headers these are defined as enums in
Expand Down
1 change: 1 addition & 0 deletions lib/netdev-linux.h
Expand Up @@ -28,5 +28,6 @@ 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);
bool netdev_linux_flow_api_supported(const struct netdev *netdev);

#endif /* netdev-linux.h */
4 changes: 4 additions & 0 deletions lib/netdev-offload-tc.c
Expand Up @@ -1643,6 +1643,10 @@ netdev_tc_init_flow_api(struct netdev *netdev)
int ifindex;
int error;

if (!netdev_linux_flow_api_supported(netdev)) {
return EOPNOTSUPP;
}

ifindex = netdev_get_ifindex(netdev);
if (ifindex < 0) {
VLOG_INFO("init: failed to get ifindex for %s: %s",
Expand Down

0 comments on commit f6d9490

Please sign in to comment.