mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
netdev: Clean up and refactor packet receive interface.
The Open vSwitch tree only has one user of the ability for a netdev to receive packets from a network device. Thus, this commit simplifies the common-case use of the netdev interface by replacing the "ethertype" option from "struct netdev_options" by a new netdev_listen() call. The only user of netdev_listen() wants to receive all packets from a network device, so this commit also removes the ability to restrict the received packets to a particular protocol. (This ability was once used by the Open vSwitch integrated DHCP client, but that code has been removed.) This commit also simplifies and improves the implementation of the code in netdev-linux that started listening to a network device. Before, I had not figured out how to avoid receiving all packets on all devices before binding to a particular device, but I took a closer look at the kernel code and figured it out. I've tested that the userspace datapath (dpif-netdev), the only user of netdev_recv(), still works after this change.
This commit is contained in:
@@ -350,7 +350,6 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
|
||||
/* Open and validate network device. */
|
||||
memset(&netdev_options, 0, sizeof netdev_options);
|
||||
netdev_options.name = devname;
|
||||
netdev_options.ethertype = NETDEV_ETH_TYPE_ANY;
|
||||
if (dp->class == &dpif_dummy_class) {
|
||||
netdev_options.type = "dummy";
|
||||
} else if (internal) {
|
||||
@@ -364,6 +363,14 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
|
||||
/* XXX reject loopback devices */
|
||||
/* XXX reject non-Ethernet devices */
|
||||
|
||||
error = netdev_listen(netdev);
|
||||
if (error) {
|
||||
VLOG_ERR("%s: cannot receive packets on this network device (%s)",
|
||||
devname, strerror(errno));
|
||||
netdev_close(netdev);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = netdev_turn_flags_on(netdev, NETDEV_PROMISC, false);
|
||||
if (error) {
|
||||
netdev_close(netdev);
|
||||
|
Reference in New Issue
Block a user