Skip to content

Commit

Permalink
datapath: Remove vport MAC address configuration.
Browse files Browse the repository at this point in the history
The ability to retrieve and set MAC addresses on vports is only
necessary for tunnel ports (the addresses for actual devices can be
retrieved through direct Linux mechanisms).  Tunnel ports only used
the information for the purpose of generating path MTU discovery
packets, which has now been removed.  Current userspace code already
reflects these changes, so this drops the functionality from the
kernel.

Signed-off-by: Jesse Gross <[email protected]>
Acked-by: Kyle Mestery <[email protected]>
  • Loading branch information
jessegross committed Jan 28, 2013
1 parent 78adaee commit 1fc7083
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 175 deletions.
47 changes: 13 additions & 34 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1787,10 +1787,8 @@ static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
#ifdef HAVE_NLA_NUL_STRING
[OVS_VPORT_ATTR_NAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
[OVS_VPORT_ATTR_STATS] = { .len = sizeof(struct ovs_vport_stats) },
[OVS_VPORT_ATTR_ADDRESS] = { .len = ETH_ALEN },
#else
[OVS_VPORT_ATTR_STATS] = { .minlen = sizeof(struct ovs_vport_stats) },
[OVS_VPORT_ATTR_ADDRESS] = { .minlen = ETH_ALEN },
#endif
[OVS_VPORT_ATTR_PORT_NO] = { .type = NLA_U32 },
[OVS_VPORT_ATTR_TYPE] = { .type = NLA_U32 },
Expand Down Expand Up @@ -1837,10 +1835,6 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,
&vport_stats))
goto nla_put_failure;

if (nla_put(skb, OVS_VPORT_ATTR_ADDRESS, ETH_ALEN,
vport->ops->get_addr(vport)))
goto nla_put_failure;

err = ovs_vport_get_options(vport, skb);
if (err == -EMSGSIZE)
goto error;
Expand Down Expand Up @@ -1912,21 +1906,6 @@ static struct vport *lookup_vport(struct net *net,
return ERR_PTR(-EINVAL);
}

/* Called with RTNL lock. */
static int change_vport(struct vport *vport,
struct nlattr *a[OVS_VPORT_ATTR_MAX + 1])
{
int err = 0;

if (a[OVS_VPORT_ATTR_STATS])
ovs_vport_set_stats(vport, nla_data(a[OVS_VPORT_ATTR_STATS]));

if (a[OVS_VPORT_ATTR_ADDRESS])
err = ovs_vport_set_addr(vport, nla_data(a[OVS_VPORT_ATTR_ADDRESS]));

return err;
}

static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr **a = info->attrs;
Expand Down Expand Up @@ -1988,15 +1967,13 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
if (IS_ERR(vport))
goto exit_unlock;

err = change_vport(vport, a);
if (!err) {
reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
info->snd_seq,
OVS_VPORT_CMD_NEW);
if (IS_ERR(reply))
err = PTR_ERR(reply);
}
if (err) {
if (a[OVS_VPORT_ATTR_STATS])
ovs_vport_set_stats(vport, nla_data(a[OVS_VPORT_ATTR_STATS]));

reply = ovs_vport_cmd_build_info(vport, info->snd_portid, info->snd_seq,
OVS_VPORT_CMD_NEW);
if (IS_ERR(reply)) {
err = PTR_ERR(reply);
ovs_dp_detach_port(vport);
goto exit_unlock;
}
Expand Down Expand Up @@ -2033,11 +2010,13 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)

if (!err && a[OVS_VPORT_ATTR_OPTIONS])
err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]);
if (!err)
err = change_vport(vport, a);
else
if (err)
goto exit_unlock;
if (!err && a[OVS_VPORT_ATTR_UPCALL_PID])

if (a[OVS_VPORT_ATTR_STATS])
ovs_vport_set_stats(vport, nla_data(a[OVS_VPORT_ATTR_STATS]));

if (a[OVS_VPORT_ATTR_UPCALL_PID])
vport->upcall_portid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]);

reply = ovs_vport_cmd_build_info(vport, info->snd_portid,
Expand Down
28 changes: 0 additions & 28 deletions datapath/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,6 @@ struct vport *ovs_tnl_create(const struct vport_parms *parms,
goto error_free_vport;
}

random_ether_addr(mutable->eth_addr);

get_random_bytes(&initial_frag_id, sizeof(int));
atomic_set(&tnl_vport->frag_id, initial_frag_id);

Expand Down Expand Up @@ -860,9 +858,7 @@ int ovs_tnl_set_options(struct vport *vport, struct nlattr *options)
goto error;
}

/* Copy fields whose values should be retained. */
mutable->seq = old_mutable->seq + 1;
memcpy(mutable->eth_addr, old_mutable->eth_addr, ETH_ALEN);

/* Parse the others configured by userspace. */
err = tnl_set_config(ovs_dp_get_net(vport->dp), options, tnl_vport->tnl_ops,
Expand Down Expand Up @@ -942,36 +938,12 @@ void ovs_tnl_destroy(struct vport *vport)
call_rcu(&tnl_vport->rcu, free_port_rcu);
}

int ovs_tnl_set_addr(struct vport *vport, const unsigned char *addr)
{
struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
struct tnl_mutable_config *old_mutable, *mutable;

old_mutable = rtnl_dereference(tnl_vport->mutable);
mutable = kmemdup(old_mutable, sizeof(struct tnl_mutable_config), GFP_KERNEL);
if (!mutable)
return -ENOMEM;

old_mutable->mlink = 0;

memcpy(mutable->eth_addr, addr, ETH_ALEN);
assign_config_rcu(vport, mutable);

return 0;
}

const char *ovs_tnl_get_name(const struct vport *vport)
{
const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
return tnl_vport->name;
}

const unsigned char *ovs_tnl_get_addr(const struct vport *vport)
{
const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
return rcu_dereference_rtnl(tnl_vport->mutable)->eth_addr;
}

void ovs_tnl_free_linked_skbs(struct sk_buff *skb)
{
while (skb) {
Expand Down
6 changes: 0 additions & 6 deletions datapath/tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ static inline void port_key_set_net(struct port_lookup_key *key, struct net *net
* @rcu: RCU callback head for deferred destruction.
* @seq: Sequence number for distinguishing configuration versions.
* @tunnel_hlen: Tunnel header length.
* @eth_addr: Source address for packets generated by tunnel itself
* (e.g. ICMP fragmentation needed messages).
* @out_key: Key to use on output, 0 if this tunnel has no fixed output key.
* @flags: TNL_F_* flags.
* @tos: IPv4 TOS value to use for tunnel, 0 if no fixed TOS.
Expand All @@ -109,8 +107,6 @@ struct tnl_mutable_config {

unsigned seq;

unsigned char eth_addr[ETH_ALEN];

/* Configured via OVS_TUNNEL_ATTR_* attributes. */
__be64 out_key;
u32 flags;
Expand Down Expand Up @@ -170,9 +166,7 @@ void ovs_tnl_destroy(struct vport *);
int ovs_tnl_set_options(struct vport *, struct nlattr *);
int ovs_tnl_get_options(const struct vport *, struct sk_buff *);

int ovs_tnl_set_addr(struct vport *vport, const unsigned char *addr);
const char *ovs_tnl_get_name(const struct vport *vport);
const unsigned char *ovs_tnl_get_addr(const struct vport *vport);
int ovs_tnl_send(struct vport *vport, struct sk_buff *skb);
void ovs_tnl_rcv(struct vport *vport, struct sk_buff *skb);

Expand Down
2 changes: 0 additions & 2 deletions datapath/vport-capwap.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,7 @@ const struct vport_ops ovs_capwap_vport_ops = {
.exit = capwap_exit,
.create = capwap_create,
.destroy = capwap_destroy,
.set_addr = ovs_tnl_set_addr,
.get_name = ovs_tnl_get_name,
.get_addr = ovs_tnl_get_addr,
.get_options = ovs_tnl_get_options,
.set_options = ovs_tnl_set_options,
.send = ovs_tnl_send,
Expand Down
6 changes: 0 additions & 6 deletions datapath/vport-gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ const struct vport_ops ovs_gre_ft_vport_ops = {
.exit = gre_exit,
.create = gre_create_ft,
.destroy = ovs_tnl_destroy,
.set_addr = ovs_tnl_set_addr,
.get_name = ovs_tnl_get_name,
.get_addr = ovs_tnl_get_addr,
.get_options = ovs_tnl_get_options,
.set_options = ovs_tnl_set_options,
.send = ovs_tnl_send,
Expand All @@ -379,9 +377,7 @@ const struct vport_ops ovs_gre_vport_ops = {
.exit = gre_exit,
.create = gre_create,
.destroy = ovs_tnl_destroy,
.set_addr = ovs_tnl_set_addr,
.get_name = ovs_tnl_get_name,
.get_addr = ovs_tnl_get_addr,
.get_options = ovs_tnl_get_options,
.set_options = ovs_tnl_set_options,
.send = ovs_tnl_send,
Expand All @@ -394,9 +390,7 @@ const struct vport_ops ovs_gre64_vport_ops = {
.exit = gre_exit,
.create = gre_create64,
.destroy = ovs_tnl_destroy,
.set_addr = ovs_tnl_set_addr,
.get_name = ovs_tnl_get_name,
.get_addr = ovs_tnl_get_addr,
.get_options = ovs_tnl_get_options,
.set_options = ovs_tnl_set_options,
.send = ovs_tnl_send,
Expand Down
2 changes: 0 additions & 2 deletions datapath/vport-internal_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ const struct vport_ops ovs_internal_vport_ops = {
.flags = VPORT_F_REQUIRED | VPORT_F_FLOW,
.create = internal_dev_create,
.destroy = internal_dev_destroy,
.set_addr = ovs_netdev_set_addr,
.get_name = ovs_netdev_get_name,
.get_addr = ovs_netdev_get_addr,
.get_ifindex = ovs_netdev_get_ifindex,
.send = internal_dev_recv,
};
Expand Down
19 changes: 0 additions & 19 deletions datapath/vport-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,29 +193,12 @@ static void netdev_destroy(struct vport *vport)
call_rcu(&netdev_vport->rcu, free_port_rcu);
}

int ovs_netdev_set_addr(struct vport *vport, const unsigned char *addr)
{
struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
struct sockaddr sa;

sa.sa_family = ARPHRD_ETHER;
memcpy(sa.sa_data, addr, ETH_ALEN);

return dev_set_mac_address(netdev_vport->dev, &sa);
}

const char *ovs_netdev_get_name(const struct vport *vport)
{
const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
return netdev_vport->dev->name;
}

const unsigned char *ovs_netdev_get_addr(const struct vport *vport)
{
const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
return netdev_vport->dev->dev_addr;
}

int ovs_netdev_get_ifindex(const struct vport *vport)
{
const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
Expand Down Expand Up @@ -383,9 +366,7 @@ const struct vport_ops ovs_netdev_vport_ops = {
.exit = netdev_exit,
.create = netdev_create,
.destroy = netdev_destroy,
.set_addr = ovs_netdev_set_addr,
.get_name = ovs_netdev_get_name,
.get_addr = ovs_netdev_get_addr,
.get_ifindex = ovs_netdev_get_ifindex,
.send = netdev_send,
};
Expand Down
2 changes: 0 additions & 2 deletions datapath/vport-netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ netdev_vport_priv(const struct vport *vport)
return vport_priv(vport);
}

int ovs_netdev_set_addr(struct vport *, const unsigned char *addr);
const char *ovs_netdev_get_name(const struct vport *);
const unsigned char *ovs_netdev_get_addr(const struct vport *);
const char *ovs_netdev_get_config(const struct vport *);
int ovs_netdev_get_ifindex(const struct vport *);

Expand Down
28 changes: 0 additions & 28 deletions datapath/vport-patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ struct patch_config {
struct rcu_head rcu;

char peer_name[IFNAMSIZ];
unsigned char eth_addr[ETH_ALEN];
};

struct patch_vport {
Expand Down Expand Up @@ -159,8 +158,6 @@ static struct vport *patch_create(const struct vport_parms *parms)
if (err)
goto error_free_patchconf;

random_ether_addr(patchconf->eth_addr);

rcu_assign_pointer(patch_vport->patchconf, patchconf);

peer_name = patchconf->peer_name;
Expand Down Expand Up @@ -246,35 +243,12 @@ static void update_peers(struct net *net, const char *name, struct vport *vport)
}
}

static int patch_set_addr(struct vport *vport, const unsigned char *addr)
{
struct patch_vport *patch_vport = patch_vport_priv(vport);
struct patch_config *patchconf;

patchconf = kmemdup(rtnl_dereference(patch_vport->patchconf),
sizeof(struct patch_config), GFP_KERNEL);
if (!patchconf)
return -ENOMEM;

memcpy(patchconf->eth_addr, addr, ETH_ALEN);
assign_config_rcu(vport, patchconf);

return 0;
}


static const char *patch_get_name(const struct vport *vport)
{
const struct patch_vport *patch_vport = patch_vport_priv(vport);
return patch_vport->name;
}

static const unsigned char *patch_get_addr(const struct vport *vport)
{
const struct patch_vport *patch_vport = patch_vport_priv(vport);
return rcu_dereference_rtnl(patch_vport->patchconf)->eth_addr;
}

static int patch_get_options(const struct vport *vport, struct sk_buff *skb)
{
struct patch_vport *patch_vport = patch_vport_priv(vport);
Expand Down Expand Up @@ -306,9 +280,7 @@ const struct vport_ops ovs_patch_vport_ops = {
.exit = patch_exit,
.create = patch_create,
.destroy = patch_destroy,
.set_addr = patch_set_addr,
.get_name = patch_get_name,
.get_addr = patch_get_addr,
.get_options = patch_get_options,
.set_options = patch_set_options,
.send = patch_send,
Expand Down
2 changes: 0 additions & 2 deletions datapath/vport-vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ const struct vport_ops ovs_vxlan_vport_ops = {
.flags = VPORT_F_TUN_ID,
.create = vxlan_tnl_create,
.destroy = vxlan_tnl_destroy,
.set_addr = ovs_tnl_set_addr,
.get_name = ovs_tnl_get_name,
.get_addr = ovs_tnl_get_addr,
.get_options = ovs_tnl_get_options,
.set_options = vxlan_set_options,
.send = ovs_tnl_send,
Expand Down
23 changes: 0 additions & 23 deletions datapath/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,29 +285,6 @@ void ovs_vport_del(struct vport *vport)
vport->ops->destroy(vport);
}

/**
* ovs_vport_set_addr - set device Ethernet address (for kernel callers)
*
* @vport: vport on which to set Ethernet address.
* @addr: New address.
*
* Sets the Ethernet address of the given device. Some devices may not support
* setting the Ethernet address, in which case the result will always be
* -EOPNOTSUPP. RTNL lock must be held.
*/
int ovs_vport_set_addr(struct vport *vport, const unsigned char *addr)
{
ASSERT_RTNL();

if (!is_valid_ether_addr(addr))
return -EADDRNOTAVAIL;

if (vport->ops->set_addr)
return vport->ops->set_addr(vport, addr);
else
return -EOPNOTSUPP;
}

/**
* ovs_vport_set_stats - sets offset device stats
*
Expand Down
Loading

0 comments on commit 1fc7083

Please sign in to comment.