diff options
author | Thomas Graf <tgraf@suug.ch> | 2013-12-13 09:22:20 -0500 |
---|---|---|
committer | Jesse Gross <jesse@nicira.com> | 2014-01-06 18:53:07 -0500 |
commit | 8055a89cfa533f70bea5970727a50e220bb7d18e (patch) | |
tree | fb62f1ecb1d52df57ccfd2e615971d8f814d5aba /net/openvswitch | |
parent | 44da5ae5fbea4686f667dc854e5ea16814e44c59 (diff) |
openvswitch: Pass datapath into userspace queue functions
Allows removing the net and dp_ifindex argument and simplify the
code.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'net/openvswitch')
-rw-r--r-- | net/openvswitch/datapath.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 497b2fd36df4..235acaeaedc7 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -108,10 +108,9 @@ int lockdep_ovsl_is_held(void) | |||
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | static struct vport *new_vport(const struct vport_parms *); | 110 | static struct vport *new_vport(const struct vport_parms *); |
111 | static int queue_gso_packets(struct net *, int dp_ifindex, struct sk_buff *, | 111 | static int queue_gso_packets(struct datapath *dp, struct sk_buff *, |
112 | const struct dp_upcall_info *); | 112 | const struct dp_upcall_info *); |
113 | static int queue_userspace_packet(struct net *, int dp_ifindex, | 113 | static int queue_userspace_packet(struct datapath *dp, struct sk_buff *, |
114 | struct sk_buff *, | ||
115 | const struct dp_upcall_info *); | 114 | const struct dp_upcall_info *); |
116 | 115 | ||
117 | /* Must be called with rcu_read_lock or ovs_mutex. */ | 116 | /* Must be called with rcu_read_lock or ovs_mutex. */ |
@@ -277,7 +276,6 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb, | |||
277 | const struct dp_upcall_info *upcall_info) | 276 | const struct dp_upcall_info *upcall_info) |
278 | { | 277 | { |
279 | struct dp_stats_percpu *stats; | 278 | struct dp_stats_percpu *stats; |
280 | int dp_ifindex; | ||
281 | int err; | 279 | int err; |
282 | 280 | ||
283 | if (upcall_info->portid == 0) { | 281 | if (upcall_info->portid == 0) { |
@@ -285,16 +283,10 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb, | |||
285 | goto err; | 283 | goto err; |
286 | } | 284 | } |
287 | 285 | ||
288 | dp_ifindex = get_dpifindex(dp); | ||
289 | if (!dp_ifindex) { | ||
290 | err = -ENODEV; | ||
291 | goto err; | ||
292 | } | ||
293 | |||
294 | if (!skb_is_gso(skb)) | 286 | if (!skb_is_gso(skb)) |
295 | err = queue_userspace_packet(ovs_dp_get_net(dp), dp_ifindex, skb, upcall_info); | 287 | err = queue_userspace_packet(dp, skb, upcall_info); |
296 | else | 288 | else |
297 | err = queue_gso_packets(ovs_dp_get_net(dp), dp_ifindex, skb, upcall_info); | 289 | err = queue_gso_packets(dp, skb, upcall_info); |
298 | if (err) | 290 | if (err) |
299 | goto err; | 291 | goto err; |
300 | 292 | ||
@@ -310,8 +302,7 @@ err: | |||
310 | return err; | 302 | return err; |
311 | } | 303 | } |
312 | 304 | ||
313 | static int queue_gso_packets(struct net *net, int dp_ifindex, | 305 | static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, |
314 | struct sk_buff *skb, | ||
315 | const struct dp_upcall_info *upcall_info) | 306 | const struct dp_upcall_info *upcall_info) |
316 | { | 307 | { |
317 | unsigned short gso_type = skb_shinfo(skb)->gso_type; | 308 | unsigned short gso_type = skb_shinfo(skb)->gso_type; |
@@ -327,7 +318,7 @@ static int queue_gso_packets(struct net *net, int dp_ifindex, | |||
327 | /* Queue all of the segments. */ | 318 | /* Queue all of the segments. */ |
328 | skb = segs; | 319 | skb = segs; |
329 | do { | 320 | do { |
330 | err = queue_userspace_packet(net, dp_ifindex, skb, upcall_info); | 321 | err = queue_userspace_packet(dp, skb, upcall_info); |
331 | if (err) | 322 | if (err) |
332 | break; | 323 | break; |
333 | 324 | ||
@@ -394,8 +385,7 @@ static size_t upcall_msg_size(const struct sk_buff *skb, | |||
394 | return size; | 385 | return size; |
395 | } | 386 | } |
396 | 387 | ||
397 | static int queue_userspace_packet(struct net *net, int dp_ifindex, | 388 | static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, |
398 | struct sk_buff *skb, | ||
399 | const struct dp_upcall_info *upcall_info) | 389 | const struct dp_upcall_info *upcall_info) |
400 | { | 390 | { |
401 | struct ovs_header *upcall; | 391 | struct ovs_header *upcall; |
@@ -403,11 +393,15 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex, | |||
403 | struct sk_buff *user_skb; /* to be queued to userspace */ | 393 | struct sk_buff *user_skb; /* to be queued to userspace */ |
404 | struct nlattr *nla; | 394 | struct nlattr *nla; |
405 | struct genl_info info = { | 395 | struct genl_info info = { |
406 | .dst_sk = net->genl_sock, | 396 | .dst_sk = ovs_dp_get_net(dp)->genl_sock, |
407 | .snd_portid = upcall_info->portid, | 397 | .snd_portid = upcall_info->portid, |
408 | }; | 398 | }; |
409 | size_t len; | 399 | size_t len; |
410 | int err; | 400 | int err, dp_ifindex; |
401 | |||
402 | dp_ifindex = get_dpifindex(dp); | ||
403 | if (!dp_ifindex) | ||
404 | return -ENODEV; | ||
411 | 405 | ||
412 | if (vlan_tx_tag_present(skb)) { | 406 | if (vlan_tx_tag_present(skb)) { |
413 | nskb = skb_clone(skb, GFP_ATOMIC); | 407 | nskb = skb_clone(skb, GFP_ATOMIC); |
@@ -452,7 +446,7 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex, | |||
452 | skb_copy_and_csum_dev(skb, nla_data(nla)); | 446 | skb_copy_and_csum_dev(skb, nla_data(nla)); |
453 | 447 | ||
454 | genlmsg_end(user_skb, upcall); | 448 | genlmsg_end(user_skb, upcall); |
455 | err = genlmsg_unicast(net, user_skb, upcall_info->portid); | 449 | err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid); |
456 | 450 | ||
457 | out: | 451 | out: |
458 | kfree_skb(nskb); | 452 | kfree_skb(nskb); |