aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/flow_netlink.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/flow_netlink.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/flow_netlink.c')
-rw-r--r--net/openvswitch/flow_netlink.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index d210d1be3470..33751f81bfcb 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -1216,12 +1216,12 @@ int ovs_nla_get_flow_metadata(const struct nlattr *attr,
1216 return metadata_from_nlattrs(&match, &attrs, a, false, log); 1216 return metadata_from_nlattrs(&match, &attrs, a, false, log);
1217} 1217}
1218 1218
1219int ovs_nla_put_flow(const struct sw_flow_key *swkey, 1219static int __ovs_nla_put_key(const struct sw_flow_key *swkey,
1220 const struct sw_flow_key *output, struct sk_buff *skb) 1220 const struct sw_flow_key *output, bool is_mask,
1221 struct sk_buff *skb)
1221{ 1222{
1222 struct ovs_key_ethernet *eth_key; 1223 struct ovs_key_ethernet *eth_key;
1223 struct nlattr *nla, *encap; 1224 struct nlattr *nla, *encap;
1224 bool is_mask = (swkey != output);
1225 1225
1226 if (nla_put_u32(skb, OVS_KEY_ATTR_RECIRC_ID, output->recirc_id)) 1226 if (nla_put_u32(skb, OVS_KEY_ATTR_RECIRC_ID, output->recirc_id))
1227 goto nla_put_failure; 1227 goto nla_put_failure;
@@ -1431,6 +1431,38 @@ nla_put_failure:
1431 return -EMSGSIZE; 1431 return -EMSGSIZE;
1432} 1432}
1433 1433
1434int ovs_nla_put_key(const struct sw_flow_key *swkey,
1435 const struct sw_flow_key *output, int attr, bool is_mask,
1436 struct sk_buff *skb)
1437{
1438 int err;
1439 struct nlattr *nla;
1440
1441 nla = nla_nest_start(skb, attr);
1442 if (!nla)
1443 return -EMSGSIZE;
1444 err = __ovs_nla_put_key(swkey, output, is_mask, skb);
1445 if (err)
1446 return err;
1447 nla_nest_end(skb, nla);
1448
1449 return 0;
1450}
1451
1452/* Called with ovs_mutex or RCU read lock. */
1453int ovs_nla_put_unmasked_key(const struct sw_flow *flow, struct sk_buff *skb)
1454{
1455 return ovs_nla_put_key(&flow->unmasked_key, &flow->unmasked_key,
1456 OVS_FLOW_ATTR_KEY, false, skb);
1457}
1458
1459/* Called with ovs_mutex or RCU read lock. */
1460int ovs_nla_put_mask(const struct sw_flow *flow, struct sk_buff *skb)
1461{
1462 return ovs_nla_put_key(&flow->key, &flow->mask->key,
1463 OVS_FLOW_ATTR_MASK, true, skb);
1464}
1465
1434#define MAX_ACTIONS_BUFSIZE (32 * 1024) 1466#define MAX_ACTIONS_BUFSIZE (32 * 1024)
1435 1467
1436static struct sw_flow_actions *nla_alloc_flow_actions(int size, bool log) 1468static struct sw_flow_actions *nla_alloc_flow_actions(int size, bool log)