openvswitch: Move key_attr_size() to flow_netlink.h.
authorJoe Stringer <joestringer@nicira.com>
Sat, 18 Oct 2014 23:14:14 +0000 (16:14 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Thu, 6 Nov 2014 07:52:35 +0000 (23:52 -0800)
flow-netlink has netlink related code.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
net/openvswitch/datapath.c
net/openvswitch/flow_netlink.c
net/openvswitch/flow_netlink.h

index 4fd8a45e5d56828cef84743b743c7fbef1ccffa3..51017805b40b41b67733e369181f1b728d659448 100644 (file)
@@ -375,37 +375,12 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
        return err;
 }
 
-static size_t key_attr_size(void)
-{
-       return    nla_total_size(4)   /* OVS_KEY_ATTR_PRIORITY */
-               + nla_total_size(0)   /* OVS_KEY_ATTR_TUNNEL */
-                 + nla_total_size(8)   /* OVS_TUNNEL_KEY_ATTR_ID */
-                 + nla_total_size(4)   /* OVS_TUNNEL_KEY_ATTR_IPV4_SRC */
-                 + nla_total_size(4)   /* OVS_TUNNEL_KEY_ATTR_IPV4_DST */
-                 + nla_total_size(1)   /* OVS_TUNNEL_KEY_ATTR_TOS */
-                 + nla_total_size(1)   /* OVS_TUNNEL_KEY_ATTR_TTL */
-                 + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */
-                 + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_CSUM */
-                 + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_OAM */
-                 + nla_total_size(256)   /* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS */
-               + nla_total_size(4)   /* OVS_KEY_ATTR_IN_PORT */
-               + nla_total_size(4)   /* OVS_KEY_ATTR_SKB_MARK */
-               + nla_total_size(12)  /* OVS_KEY_ATTR_ETHERNET */
-               + nla_total_size(2)   /* OVS_KEY_ATTR_ETHERTYPE */
-               + nla_total_size(4)   /* OVS_KEY_ATTR_8021Q */
-               + nla_total_size(0)   /* OVS_KEY_ATTR_ENCAP */
-               + nla_total_size(2)   /* OVS_KEY_ATTR_ETHERTYPE */
-               + nla_total_size(40)  /* OVS_KEY_ATTR_IPV6 */
-               + nla_total_size(2)   /* OVS_KEY_ATTR_ICMPV6 */
-               + nla_total_size(28); /* OVS_KEY_ATTR_ND */
-}
-
 static size_t upcall_msg_size(const struct nlattr *userdata,
                              unsigned int hdrlen)
 {
        size_t size = NLMSG_ALIGN(sizeof(struct ovs_header))
                + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */
-               + nla_total_size(key_attr_size()); /* OVS_PACKET_ATTR_KEY */
+               + nla_total_size(ovs_key_attr_size()); /* OVS_PACKET_ATTR_KEY */
 
        /* OVS_PACKET_ATTR_USERDATA */
        if (userdata)
@@ -678,8 +653,8 @@ static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats,
 static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts)
 {
        return NLMSG_ALIGN(sizeof(struct ovs_header))
-               + nla_total_size(key_attr_size()) /* OVS_FLOW_ATTR_KEY */
-               + nla_total_size(key_attr_size()) /* OVS_FLOW_ATTR_MASK */
+               + nla_total_size(ovs_key_attr_size()) /* OVS_FLOW_ATTR_KEY */
+               + nla_total_size(ovs_key_attr_size()) /* OVS_FLOW_ATTR_MASK */
                + nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */
                + nla_total_size(1) /* OVS_FLOW_ATTR_TCP_FLAGS */
                + nla_total_size(8) /* OVS_FLOW_ATTR_USED */
index 1b29ea7069122aa62380c6ce2906f9881f0cfcc1..1050b2882b9e3f2a2b4fca5721201bddd7e50462 100644 (file)
@@ -252,6 +252,38 @@ static bool match_validate(const struct sw_flow_match *match,
        return true;
 }
 
+size_t ovs_key_attr_size(void)
+{
+       /* Whenever adding new OVS_KEY_ FIELDS, we should consider
+        * updating this function.
+        */
+       BUILD_BUG_ON(OVS_KEY_ATTR_TUNNEL_INFO != 22);
+
+       return    nla_total_size(4)   /* OVS_KEY_ATTR_PRIORITY */
+               + nla_total_size(0)   /* OVS_KEY_ATTR_TUNNEL */
+                 + nla_total_size(8)   /* OVS_TUNNEL_KEY_ATTR_ID */
+                 + nla_total_size(4)   /* OVS_TUNNEL_KEY_ATTR_IPV4_SRC */
+                 + nla_total_size(4)   /* OVS_TUNNEL_KEY_ATTR_IPV4_DST */
+                 + nla_total_size(1)   /* OVS_TUNNEL_KEY_ATTR_TOS */
+                 + nla_total_size(1)   /* OVS_TUNNEL_KEY_ATTR_TTL */
+                 + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */
+                 + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_CSUM */
+                 + nla_total_size(0)   /* OVS_TUNNEL_KEY_ATTR_OAM */
+                 + nla_total_size(256) /* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS */
+               + nla_total_size(4)   /* OVS_KEY_ATTR_IN_PORT */
+               + nla_total_size(4)   /* OVS_KEY_ATTR_SKB_MARK */
+               + nla_total_size(4)   /* OVS_KEY_ATTR_DP_HASH */
+               + nla_total_size(4)   /* OVS_KEY_ATTR_RECIRC_ID */
+               + nla_total_size(12)  /* OVS_KEY_ATTR_ETHERNET */
+               + nla_total_size(2)   /* OVS_KEY_ATTR_ETHERTYPE */
+               + nla_total_size(4)   /* OVS_KEY_ATTR_VLAN */
+               + nla_total_size(0)   /* OVS_KEY_ATTR_ENCAP */
+               + nla_total_size(2)   /* OVS_KEY_ATTR_ETHERTYPE */
+               + nla_total_size(40)  /* OVS_KEY_ATTR_IPV6 */
+               + nla_total_size(2)   /* OVS_KEY_ATTR_ICMPV6 */
+               + nla_total_size(28); /* OVS_KEY_ATTR_ND */
+}
+
 /* The size of the argument for each %OVS_KEY_ATTR_* Netlink attribute.  */
 static const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
        [OVS_KEY_ATTR_ENCAP] = -1,
index 6355b1d01329c6073db9c307748cabee985e825d..4f0370646bc69b4cce96cfaf81e7fd2b9cb36179 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "flow.h"
 
+size_t ovs_key_attr_size(void);
+
 void ovs_match_init(struct sw_flow_match *match,
                    struct sw_flow_key *key, struct sw_flow_mask *mask);