aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2014-09-15 22:15:28 -0400
committerPravin B Shelar <pshelar@nicira.com>2014-09-16 02:28:13 -0400
commit2ff3e4e4868675da1024175215991fa6d9856731 (patch)
tree4734d124ac5208aff9445e59054e856a9126eda0 /net/openvswitch
parentc1f570a6abc192f047550743f9957b617af605af (diff)
openvswitch: Remove pkt_key from OVS_CB
OVS keeps pointer to packet key in skb->cb, but the packet key is store on stack. This could make code bit tricky. So it is better to get rid of the pointer. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'net/openvswitch')
-rw-r--r--net/openvswitch/actions.c22
-rw-r--r--net/openvswitch/datapath.c6
-rw-r--r--net/openvswitch/datapath.h5
3 files changed, 16 insertions, 17 deletions
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 5231652a95d9..8a1eb562cdec 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -38,6 +38,7 @@
38#include "vport.h" 38#include "vport.h"
39 39
40static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, 40static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
41 struct sw_flow_key *key,
41 const struct nlattr *attr, int len); 42 const struct nlattr *attr, int len);
42 43
43static int make_writable(struct sk_buff *skb, int write_len) 44static int make_writable(struct sk_buff *skb, int write_len)
@@ -410,16 +411,14 @@ static int do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
410} 411}
411 412
412static int output_userspace(struct datapath *dp, struct sk_buff *skb, 413static int output_userspace(struct datapath *dp, struct sk_buff *skb,
413 const struct nlattr *attr) 414 struct sw_flow_key *key, const struct nlattr *attr)
414{ 415{
415 struct dp_upcall_info upcall; 416 struct dp_upcall_info upcall;
416 const struct nlattr *a; 417 const struct nlattr *a;
417 int rem; 418 int rem;
418 419
419 BUG_ON(!OVS_CB(skb)->pkt_key);
420
421 upcall.cmd = OVS_PACKET_CMD_ACTION; 420 upcall.cmd = OVS_PACKET_CMD_ACTION;
422 upcall.key = OVS_CB(skb)->pkt_key; 421 upcall.key = key;
423 upcall.userdata = NULL; 422 upcall.userdata = NULL;
424 upcall.portid = 0; 423 upcall.portid = 0;
425 424
@@ -445,7 +444,7 @@ static bool last_action(const struct nlattr *a, int rem)
445} 444}
446 445
447static int sample(struct datapath *dp, struct sk_buff *skb, 446static int sample(struct datapath *dp, struct sk_buff *skb,
448 const struct nlattr *attr) 447 struct sw_flow_key *key, const struct nlattr *attr)
449{ 448{
450 const struct nlattr *acts_list = NULL; 449 const struct nlattr *acts_list = NULL;
451 const struct nlattr *a; 450 const struct nlattr *a;
@@ -493,7 +492,7 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
493 * return the error code and let the caller (also 492 * return the error code and let the caller (also
494 * do_execute_actions()) free skb on error. 493 * do_execute_actions()) free skb on error.
495 */ 494 */
496 return do_execute_actions(dp, sample_skb, a, rem); 495 return do_execute_actions(dp, sample_skb, key, a, rem);
497} 496}
498 497
499static int execute_set_action(struct sk_buff *skb, 498static int execute_set_action(struct sk_buff *skb,
@@ -544,6 +543,7 @@ static int execute_set_action(struct sk_buff *skb,
544 543
545/* Execute a list of actions against 'skb'. */ 544/* Execute a list of actions against 'skb'. */
546static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, 545static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
546 struct sw_flow_key *key,
547 const struct nlattr *attr, int len) 547 const struct nlattr *attr, int len)
548{ 548{
549 /* Every output action needs a separate clone of 'skb', but the common 549 /* Every output action needs a separate clone of 'skb', but the common
@@ -569,7 +569,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
569 break; 569 break;
570 570
571 case OVS_ACTION_ATTR_USERSPACE: 571 case OVS_ACTION_ATTR_USERSPACE:
572 output_userspace(dp, skb, a); 572 output_userspace(dp, skb, key, a);
573 break; 573 break;
574 574
575 case OVS_ACTION_ATTR_PUSH_VLAN: 575 case OVS_ACTION_ATTR_PUSH_VLAN:
@@ -587,7 +587,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
587 break; 587 break;
588 588
589 case OVS_ACTION_ATTR_SAMPLE: 589 case OVS_ACTION_ATTR_SAMPLE:
590 err = sample(dp, skb, a); 590 err = sample(dp, skb, key, a);
591 if (unlikely(err)) /* skb already freed. */ 591 if (unlikely(err)) /* skb already freed. */
592 return err; 592 return err;
593 break; 593 break;
@@ -608,10 +608,12 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
608} 608}
609 609
610/* Execute a list of actions against 'skb'. */ 610/* Execute a list of actions against 'skb'. */
611int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb) 611int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
612 struct sw_flow_key *key)
612{ 613{
613 struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts); 614 struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts);
614 615
615 OVS_CB(skb)->tun_key = NULL; 616 OVS_CB(skb)->tun_key = NULL;
616 return do_execute_actions(dp, skb, acts->actions, acts->actions_len); 617 return do_execute_actions(dp, skb, key,
618 acts->actions, acts->actions_len);
617} 619}
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 91d66b7e64ac..458096da138a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -275,10 +275,9 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
275 } 275 }
276 276
277 OVS_CB(skb)->flow = flow; 277 OVS_CB(skb)->flow = flow;
278 OVS_CB(skb)->pkt_key = &key;
279 278
280 ovs_flow_stats_update(OVS_CB(skb)->flow, key.tp.flags, skb); 279 ovs_flow_stats_update(OVS_CB(skb)->flow, key.tp.flags, skb);
281 ovs_execute_actions(dp, skb); 280 ovs_execute_actions(dp, skb, &key);
282 stats_counter = &stats->n_hit; 281 stats_counter = &stats->n_hit;
283 282
284out: 283out:
@@ -568,7 +567,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
568 goto err_flow_free; 567 goto err_flow_free;
569 568
570 OVS_CB(packet)->flow = flow; 569 OVS_CB(packet)->flow = flow;
571 OVS_CB(packet)->pkt_key = &flow->key;
572 packet->priority = flow->key.phy.priority; 570 packet->priority = flow->key.phy.priority;
573 packet->mark = flow->key.phy.skb_mark; 571 packet->mark = flow->key.phy.skb_mark;
574 572
@@ -579,7 +577,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
579 goto err_unlock; 577 goto err_unlock;
580 578
581 local_bh_disable(); 579 local_bh_disable();
582 err = ovs_execute_actions(dp, packet); 580 err = ovs_execute_actions(dp, packet, &flow->key);
583 local_bh_enable(); 581 local_bh_enable();
584 rcu_read_unlock(); 582 rcu_read_unlock();
585 583
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 701b5738c38a..b576483aab7c 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -95,13 +95,11 @@ struct datapath {
95/** 95/**
96 * struct ovs_skb_cb - OVS data in skb CB 96 * struct ovs_skb_cb - OVS data in skb CB
97 * @flow: The flow associated with this packet. May be %NULL if no flow. 97 * @flow: The flow associated with this packet. May be %NULL if no flow.
98 * @pkt_key: The flow information extracted from the packet. Must be nonnull.
99 * @tun_key: Key for the tunnel that encapsulated this packet. NULL if the 98 * @tun_key: Key for the tunnel that encapsulated this packet. NULL if the
100 * packet is not being tunneled. 99 * packet is not being tunneled.
101 */ 100 */
102struct ovs_skb_cb { 101struct ovs_skb_cb {
103 struct sw_flow *flow; 102 struct sw_flow *flow;
104 struct sw_flow_key *pkt_key;
105 struct ovs_key_ipv4_tunnel *tun_key; 103 struct ovs_key_ipv4_tunnel *tun_key;
106}; 104};
107#define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb) 105#define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
@@ -191,7 +189,8 @@ int ovs_dp_upcall(struct datapath *, struct sk_buff *,
191struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq, 189struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
192 u8 cmd); 190 u8 cmd);
193 191
194int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb); 192int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
193 struct sw_flow_key *);
195void ovs_dp_notify_wq(struct work_struct *work); 194void ovs_dp_notify_wq(struct work_struct *work);
196 195
197#define OVS_NLERR(fmt, ...) \ 196#define OVS_NLERR(fmt, ...) \