aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/datapath.c
diff options
context:
space:
mode:
authorJoe Stringer <joestringer@nicira.com>2015-01-21 19:42:48 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-26 18:45:49 -0500
commit5b4237bbc93b1b54d35b037cfc0ece71cd8e358d (patch)
treea4a7e22a7f0c77b44f48fce7eef3903cf9e5fae1 /net/openvswitch/datapath.c
parent707d79e5cdcf7833d31fea9712f11b185ce25822 (diff)
openvswitch: Refactor ovs_nla_fill_match().
Refactor the ovs_nla_fill_match() function into separate netlink serialization functions ovs_nla_put_{unmasked_key,mask}(). Modify ovs_nla_put_flow() to handle attribute nesting and expose the 'is_mask' parameter - all callers need to nest the flow, and callers have better knowledge about whether it is serializing a mask or not. Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r--net/openvswitch/datapath.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index f45f1bf4422c..257b97546b33 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -461,10 +461,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
461 0, upcall_info->cmd); 461 0, upcall_info->cmd);
462 upcall->dp_ifindex = dp_ifindex; 462 upcall->dp_ifindex = dp_ifindex;
463 463
464 nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY); 464 err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb);
465 err = ovs_nla_put_flow(key, key, user_skb);
466 BUG_ON(err); 465 BUG_ON(err);
467 nla_nest_end(user_skb, nla);
468 466
469 if (upcall_info->userdata) 467 if (upcall_info->userdata)
470 __nla_put(user_skb, OVS_PACKET_ATTR_USERDATA, 468 __nla_put(user_skb, OVS_PACKET_ATTR_USERDATA,
@@ -676,37 +674,6 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts)
676} 674}
677 675
678/* Called with ovs_mutex or RCU read lock. */ 676/* Called with ovs_mutex or RCU read lock. */
679static int ovs_flow_cmd_fill_match(const struct sw_flow *flow,
680 struct sk_buff *skb)
681{
682 struct nlattr *nla;
683 int err;
684
685 /* Fill flow key. */
686 nla = nla_nest_start(skb, OVS_FLOW_ATTR_KEY);
687 if (!nla)
688 return -EMSGSIZE;
689
690 err = ovs_nla_put_flow(&flow->unmasked_key, &flow->unmasked_key, skb);
691 if (err)
692 return err;
693
694 nla_nest_end(skb, nla);
695
696 /* Fill flow mask. */
697 nla = nla_nest_start(skb, OVS_FLOW_ATTR_MASK);
698 if (!nla)
699 return -EMSGSIZE;
700
701 err = ovs_nla_put_flow(&flow->key, &flow->mask->key, skb);
702 if (err)
703 return err;
704
705 nla_nest_end(skb, nla);
706 return 0;
707}
708
709/* Called with ovs_mutex or RCU read lock. */
710static int ovs_flow_cmd_fill_stats(const struct sw_flow *flow, 677static int ovs_flow_cmd_fill_stats(const struct sw_flow *flow,
711 struct sk_buff *skb) 678 struct sk_buff *skb)
712{ 679{
@@ -787,7 +754,11 @@ static int ovs_flow_cmd_fill_info(const struct sw_flow *flow, int dp_ifindex,
787 754
788 ovs_header->dp_ifindex = dp_ifindex; 755 ovs_header->dp_ifindex = dp_ifindex;
789 756
790 err = ovs_flow_cmd_fill_match(flow, skb); 757 err = ovs_nla_put_unmasked_key(flow, skb);
758 if (err)
759 goto error;
760
761 err = ovs_nla_put_mask(flow, skb);
791 if (err) 762 if (err)
792 goto error; 763 goto error;
793 764