mirror of
https://github.com/openvswitch/ovs
synced 2025-10-29 15:28:56 +00:00
lib/netdev-dpdk: make device name parsing more robust
Current implementation of dpdk_dev_parse_name does not perform a robust error handling, port names as "dpdkr" and "dpdkr1x" are considered valid. With this patch only positive port numbers in decimal notation are considered valid. Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it> Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
This commit is contained in:
committed by
Daniele Di Proietto
parent
1f661ac7b8
commit
b83a2df1c5
@@ -188,7 +188,7 @@ struct dpdk_ring {
|
|||||||
/* For the client rings */
|
/* For the client rings */
|
||||||
struct rte_ring *cring_tx;
|
struct rte_ring *cring_tx;
|
||||||
struct rte_ring *cring_rx;
|
struct rte_ring *cring_rx;
|
||||||
int user_port_id; /* User given port no, parsed from port name */
|
unsigned int user_port_id; /* User given port no, parsed from port name */
|
||||||
int eth_port_id; /* ethernet device port id */
|
int eth_port_id; /* ethernet device port id */
|
||||||
struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
|
struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
|
||||||
};
|
};
|
||||||
@@ -635,6 +635,8 @@ unlock:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* dev_name must be the prefix followed by a positive decimal number.
|
||||||
|
* (no leading + or - signs are allowed) */
|
||||||
static int
|
static int
|
||||||
dpdk_dev_parse_name(const char dev_name[], const char prefix[],
|
dpdk_dev_parse_name(const char dev_name[], const char prefix[],
|
||||||
unsigned int *port_no)
|
unsigned int *port_no)
|
||||||
@@ -646,8 +648,12 @@ dpdk_dev_parse_name(const char dev_name[], const char prefix[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
cport = dev_name + strlen(prefix);
|
cport = dev_name + strlen(prefix);
|
||||||
*port_no = strtol(cport, NULL, 0); /* string must be null terminated */
|
|
||||||
return 0;
|
if (str_to_uint(cport, 10, port_no)) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return ENODEV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
Reference in New Issue
Block a user