Skip to content

Commit c9db965

Browse files
tgrafdavem330
authored andcommitted
openvswitch: Abstract vport name through ovs_vport_name()
This allows to get rid of the get_name() vport ops later on. Signed-off-by: Thomas Graf <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent be4ace6 commit c9db965

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

net/openvswitch/datapath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static inline struct datapath *get_dp(struct net *net, int dp_ifindex)
176176
const char *ovs_dp_name(const struct datapath *dp)
177177
{
178178
struct vport *vport = ovs_vport_ovsl_rcu(dp, OVSP_LOCAL);
179-
return vport->ops->get_name(vport);
179+
return ovs_vport_name(vport);
180180
}
181181

182182
static int get_dpifindex(const struct datapath *dp)
@@ -1800,7 +1800,7 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,
18001800
if (nla_put_u32(skb, OVS_VPORT_ATTR_PORT_NO, vport->port_no) ||
18011801
nla_put_u32(skb, OVS_VPORT_ATTR_TYPE, vport->ops->type) ||
18021802
nla_put_string(skb, OVS_VPORT_ATTR_NAME,
1803-
vport->ops->get_name(vport)))
1803+
ovs_vport_name(vport)))
18041804
goto nla_put_failure;
18051805

18061806
ovs_vport_get_stats(vport, &vport_stats);

net/openvswitch/vport-internal_dev.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ static struct vport_ops ovs_internal_vport_ops = {
242242
.type = OVS_VPORT_TYPE_INTERNAL,
243243
.create = internal_dev_create,
244244
.destroy = internal_dev_destroy,
245-
.get_name = ovs_netdev_get_name,
246245
.send = internal_dev_recv,
247246
};
248247

net/openvswitch/vport-netdev.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ static void netdev_destroy(struct vport *vport)
171171
call_rcu(&vport->rcu, free_port_rcu);
172172
}
173173

174-
const char *ovs_netdev_get_name(const struct vport *vport)
175-
{
176-
return vport->dev->name;
177-
}
178-
179174
static unsigned int packet_length(const struct sk_buff *skb)
180175
{
181176
unsigned int length = skb->len - ETH_HLEN;
@@ -223,7 +218,6 @@ static struct vport_ops ovs_netdev_vport_ops = {
223218
.type = OVS_VPORT_TYPE_NETDEV,
224219
.create = netdev_create,
225220
.destroy = netdev_destroy,
226-
.get_name = ovs_netdev_get_name,
227221
.send = netdev_send,
228222
};
229223

net/openvswitch/vport-netdev.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
struct vport *ovs_netdev_get_vport(struct net_device *dev);
2828

29-
const char *ovs_netdev_get_name(const struct vport *);
3029
void ovs_netdev_detach_dev(struct vport *);
3130

3231
int __init ovs_netdev_init(void);

net/openvswitch/vport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct vport *ovs_vport_locate(const struct net *net, const char *name)
113113
struct vport *vport;
114114

115115
hlist_for_each_entry_rcu(vport, bucket, hash_node)
116-
if (!strcmp(name, vport->ops->get_name(vport)) &&
116+
if (!strcmp(name, ovs_vport_name(vport)) &&
117117
net_eq(ovs_dp_get_net(vport->dp), net))
118118
return vport;
119119

@@ -226,7 +226,7 @@ struct vport *ovs_vport_add(const struct vport_parms *parms)
226226
}
227227

228228
bucket = hash_bucket(ovs_dp_get_net(vport->dp),
229-
vport->ops->get_name(vport));
229+
ovs_vport_name(vport));
230230
hlist_add_head_rcu(&vport->hash_node, bucket);
231231
return vport;
232232
}

net/openvswitch/vport.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ static inline void ovs_skb_postpush_rcsum(struct sk_buff *skb,
237237
skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
238238
}
239239

240+
static inline const char *ovs_vport_name(struct vport *vport)
241+
{
242+
return vport->dev ? vport->dev->name : vport->ops->get_name(vport);
243+
}
244+
240245
int ovs_vport_ops_register(struct vport_ops *ops);
241246
void ovs_vport_ops_unregister(struct vport_ops *ops);
242247

0 commit comments

Comments
 (0)