2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev: Factor restoring flags into new "struct netdev_saved_flags".

This gets rid of the only per-instance data in "struct netdev", which
will make it possible to merge "struct netdev_dev" into "struct netdev" in
a later commit.

Ed Maste wrote the netdev-bsd changes in this commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Ed Maste <emaste@freebsd.org>
Tested-by: Ed Maste <emaste@freebsd.org>
This commit is contained in:
Ben Pfaff
2013-05-10 08:55:25 -07:00
parent 0ad90c845b
commit 4b60911067
11 changed files with 175 additions and 134 deletions

View File

@@ -106,6 +106,7 @@ struct dp_netdev_port {
int port_no; /* Index into dp_netdev's 'ports'. */
struct list node; /* Element in dp_netdev's 'port_list'. */
struct netdev *netdev;
struct netdev_saved_flags *sf;
char *type; /* Port type as requested by user. */
};
@@ -374,6 +375,7 @@ static int
do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
uint32_t port_no)
{
struct netdev_saved_flags *sf;
struct dp_netdev_port *port;
struct netdev *netdev;
const char *open_type;
@@ -400,7 +402,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
return error;
}
error = netdev_turn_flags_on(netdev, NETDEV_PROMISC, false);
error = netdev_turn_flags_on(netdev, NETDEV_PROMISC, &sf);
if (error) {
netdev_close(netdev);
return error;
@@ -409,6 +411,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
port = xmalloc(sizeof *port);
port->port_no = port_no;
port->netdev = netdev;
port->sf = sf;
port->type = xstrdup(type);
error = netdev_get_mtu(netdev, &mtu);
@@ -505,6 +508,7 @@ do_del_port(struct dp_netdev *dp, uint32_t port_no)
dp->serial++;
netdev_close(port->netdev);
netdev_restore_flags(port->sf);
free(port->type);
free(port);