net/tap: remove Linux version check

Remove checks of Linux kernel version
in order to support kernel with backported features.

the expected behavior with a kernel that doesn't support flower
and other bits is the following:
        -flow validate can return successfully
        -flow create using the same rule fails.

Using the "remote" feature without kernel flower does not fail silently.
The TAP instance is not initialized if the requested parameters cannot
be satisfied.

it has been tested on an old kernel without required support:

PMD: Kernel refused TC filter rule creation (2): No such file or directory
PMD: tap0 failed to create implicit rules.
PMD: Can't set up remote feature: No such file of directory(2)
PMD: TAP Unable to initialize net_tap0

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
Acked-by: Pascal Mazon <pascal.mazon@6wind.com>
This commit is contained in:
Raslan Darawsheh 2017-07-17 12:00:20 +03:00 committed by Ferruh Yigit
parent 627a32214f
commit 7c2d03d65f
3 changed files with 6 additions and 50 deletions

View File

@ -1166,23 +1166,6 @@ static const struct eth_dev_ops ops = {
.filter_ctrl = tap_dev_filter_ctrl, .filter_ctrl = tap_dev_filter_ctrl,
}; };
static int
tap_kernel_support(struct pmd_internals *pmd)
{
struct utsname utsname;
int ver[3];
if (uname(&utsname) == -1 ||
sscanf(utsname.release, "%d.%d.%d",
&ver[0], &ver[1], &ver[2]) != 3)
return 0;
if (KERNEL_VERSION(ver[0], ver[1], ver[2]) >= FLOWER_KERNEL_VERSION)
pmd->flower_support = 1;
if (KERNEL_VERSION(ver[0], ver[1], ver[2]) >=
FLOWER_VLAN_KERNEL_VERSION)
pmd->flower_vlan_support = 1;
return 1;
}
static int static int
eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
@ -1271,21 +1254,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0) if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0)
goto error_exit; goto error_exit;
tap_kernel_support(pmd);
if (!pmd->flower_support) {
if (remote_iface[0]) {
RTE_LOG(ERR, PMD,
"%s: kernel does not support TC rules, required for remote feature.\n",
pmd->name);
goto error_exit;
} else {
RTE_LOG(INFO, PMD,
"%s: kernel too old for Flow API support.\n",
pmd->name);
return 0;
}
}
/* /*
* Set up everything related to rte_flow: * Set up everything related to rte_flow:
* - netlink socket * - netlink socket
@ -1378,7 +1346,6 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
RTE_LOG(ERR, PMD, "Remote feature requires flow support.\n"); RTE_LOG(ERR, PMD, "Remote feature requires flow support.\n");
goto error_exit; goto error_exit;
} }
pmd->flower_support = 0;
return 0; return 0;
error_remote: error_remote:
@ -1543,7 +1510,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
return 0; return 0;
internals = eth_dev->data->dev_private; internals = eth_dev->data->dev_private;
if (internals->flower_support && internals->nlsk_fd) { if (internals->nlsk_fd) {
tap_flow_flush(eth_dev, NULL); tap_flow_flush(eth_dev, NULL);
tap_flow_implicit_flush(internals, NULL); tap_flow_implicit_flush(internals, NULL);
nl_final(internals->nlsk_fd); nl_final(internals->nlsk_fd);

View File

@ -90,8 +90,6 @@ struct pmd_internals {
int ioctl_sock; /* socket for ioctl calls */ int ioctl_sock; /* socket for ioctl calls */
int nlsk_fd; /* Netlink socket fd */ int nlsk_fd; /* Netlink socket fd */
int flow_isolate; /* 1 if flow isolation is enabled */ int flow_isolate; /* 1 if flow isolation is enabled */
int flower_support; /* 1 if kernel supports, else 0 */
int flower_vlan_support; /* 1 if kernel supports, else 0 */
LIST_HEAD(tap_flows, rte_flow) flows; /* rte_flow rules */ LIST_HEAD(tap_flows, rte_flow) flows; /* rte_flow rules */
/* implicit rte_flow rules set when a remote device is active */ /* implicit rte_flow rules set when a remote device is active */
LIST_HEAD(tap_implicit_flows, rte_flow) implicit_flows; LIST_HEAD(tap_implicit_flows, rte_flow) implicit_flows;

View File

@ -1034,16 +1034,13 @@ priv_flow_process(struct pmd_internals *pmd,
if (err) if (err)
goto exit_item_not_supported; goto exit_item_not_supported;
if (flow && cur_item->convert) { if (flow && cur_item->convert) {
if (!pmd->flower_vlan_support &&
cur_item->convert == tap_flow_create_vlan)
goto exit_item_not_supported;
err = cur_item->convert(items, &data); err = cur_item->convert(items, &data);
if (err) if (err)
goto exit_item_not_supported; goto exit_item_not_supported;
} }
} }
if (flow) { if (flow) {
if (pmd->flower_vlan_support && data.vlan) { if (data.vlan) {
nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE, nlattr_add16(&flow->msg.nh, TCA_FLOWER_KEY_ETH_TYPE,
htons(ETH_P_8021Q)); htons(ETH_P_8021Q));
nlattr_add16(&flow->msg.nh, nlattr_add16(&flow->msg.nh,
@ -1231,7 +1228,8 @@ tap_flow_create(struct rte_eth_dev *dev,
"Kernel refused TC filter rule creation (%d): %s\n", "Kernel refused TC filter rule creation (%d): %s\n",
errno, strerror(errno)); errno, strerror(errno));
rte_flow_error_set(error, EEXIST, RTE_FLOW_ERROR_TYPE_HANDLE, rte_flow_error_set(error, EEXIST, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "overlapping rules"); NULL,
"overlapping rules or Kernel too old for flower support");
goto fail; goto fail;
} }
LIST_INSERT_HEAD(&pmd->flows, flow, next); LIST_INSERT_HEAD(&pmd->flows, flow, next);
@ -1276,7 +1274,8 @@ tap_flow_create(struct rte_eth_dev *dev,
errno, strerror(errno)); errno, strerror(errno));
rte_flow_error_set( rte_flow_error_set(
error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "overlapping rules"); NULL,
"overlapping rules or Kernel too old for flower support");
goto fail; goto fail;
} }
flow->remote_flow = remote_flow; flow->remote_flow = remote_flow;
@ -1393,10 +1392,6 @@ tap_flow_isolate(struct rte_eth_dev *dev,
{ {
struct pmd_internals *pmd = dev->data->dev_private; struct pmd_internals *pmd = dev->data->dev_private;
if (!pmd->flower_support)
return -rte_flow_error_set(
error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
"rte_flow isolate requires TC flower kernel support");
if (set) if (set)
pmd->flow_isolate = 1; pmd->flow_isolate = 1;
else else
@ -1642,10 +1637,6 @@ tap_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_op filter_op, enum rte_filter_op filter_op,
void *arg) void *arg)
{ {
struct pmd_internals *pmd = dev->data->dev_private;
if (!pmd->flower_support)
return -ENOTSUP;
switch (filter_type) { switch (filter_type) {
case RTE_ETH_FILTER_GENERIC: case RTE_ETH_FILTER_GENERIC:
if (filter_op != RTE_ETH_FILTER_GET) if (filter_op != RTE_ETH_FILTER_GET)