diff options
| -rw-r--r-- | net/openvswitch/datapath.c | 31 | ||||
| -rw-r--r-- | net/openvswitch/flow_netlink.c | 32 | ||||
| -rw-r--r-- | net/openvswitch/flow_netlink.h | 2 |
3 files changed, 37 insertions, 28 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 4fd8a45e5d56..51017805b40b 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
| @@ -375,37 +375,12 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, | |||
| 375 | return err; | 375 | return err; |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | static size_t key_attr_size(void) | ||
| 379 | { | ||
| 380 | return nla_total_size(4) /* OVS_KEY_ATTR_PRIORITY */ | ||
| 381 | + nla_total_size(0) /* OVS_KEY_ATTR_TUNNEL */ | ||
| 382 | + nla_total_size(8) /* OVS_TUNNEL_KEY_ATTR_ID */ | ||
| 383 | + nla_total_size(4) /* OVS_TUNNEL_KEY_ATTR_IPV4_SRC */ | ||
| 384 | + nla_total_size(4) /* OVS_TUNNEL_KEY_ATTR_IPV4_DST */ | ||
| 385 | + nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TOS */ | ||
| 386 | + nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TTL */ | ||
| 387 | + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */ | ||
| 388 | + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_CSUM */ | ||
| 389 | + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_OAM */ | ||
| 390 | + nla_total_size(256) /* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS */ | ||
| 391 | + nla_total_size(4) /* OVS_KEY_ATTR_IN_PORT */ | ||
| 392 | + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */ | ||
| 393 | + nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */ | ||
| 394 | + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ | ||
| 395 | + nla_total_size(4) /* OVS_KEY_ATTR_8021Q */ | ||
| 396 | + nla_total_size(0) /* OVS_KEY_ATTR_ENCAP */ | ||
| 397 | + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ | ||
| 398 | + nla_total_size(40) /* OVS_KEY_ATTR_IPV6 */ | ||
| 399 | + nla_total_size(2) /* OVS_KEY_ATTR_ICMPV6 */ | ||
| 400 | + nla_total_size(28); /* OVS_KEY_ATTR_ND */ | ||
| 401 | } | ||
| 402 | |||
| 403 | static size_t upcall_msg_size(const struct nlattr *userdata, | 378 | static size_t upcall_msg_size(const struct nlattr *userdata, |
| 404 | unsigned int hdrlen) | 379 | unsigned int hdrlen) |
| 405 | { | 380 | { |
| 406 | size_t size = NLMSG_ALIGN(sizeof(struct ovs_header)) | 381 | size_t size = NLMSG_ALIGN(sizeof(struct ovs_header)) |
| 407 | + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */ | 382 | + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */ |
| 408 | + nla_total_size(key_attr_size()); /* OVS_PACKET_ATTR_KEY */ | 383 | + nla_total_size(ovs_key_attr_size()); /* OVS_PACKET_ATTR_KEY */ |
| 409 | 384 | ||
| 410 | /* OVS_PACKET_ATTR_USERDATA */ | 385 | /* OVS_PACKET_ATTR_USERDATA */ |
| 411 | if (userdata) | 386 | if (userdata) |
| @@ -678,8 +653,8 @@ static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats, | |||
| 678 | static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts) | 653 | static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts) |
| 679 | { | 654 | { |
| 680 | return NLMSG_ALIGN(sizeof(struct ovs_header)) | 655 | return NLMSG_ALIGN(sizeof(struct ovs_header)) |
| 681 | + nla_total_size(key_attr_size()) /* OVS_FLOW_ATTR_KEY */ | 656 | + nla_total_size(ovs_key_attr_size()) /* OVS_FLOW_ATTR_KEY */ |
| 682 | + nla_total_size(key_attr_size()) /* OVS_FLOW_ATTR_MASK */ | 657 | + nla_total_size(ovs_key_attr_size()) /* OVS_FLOW_ATTR_MASK */ |
| 683 | + nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */ | 658 | + nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */ |
| 684 | + nla_total_size(1) /* OVS_FLOW_ATTR_TCP_FLAGS */ | 659 | + nla_total_size(1) /* OVS_FLOW_ATTR_TCP_FLAGS */ |
| 685 | + nla_total_size(8) /* OVS_FLOW_ATTR_USED */ | 660 | + nla_total_size(8) /* OVS_FLOW_ATTR_USED */ |
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 1b29ea706912..1050b2882b9e 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c | |||
| @@ -252,6 +252,38 @@ static bool match_validate(const struct sw_flow_match *match, | |||
| 252 | return true; | 252 | return true; |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | size_t ovs_key_attr_size(void) | ||
| 256 | { | ||
| 257 | /* Whenever adding new OVS_KEY_ FIELDS, we should consider | ||
| 258 | * updating this function. | ||
| 259 | */ | ||
| 260 | BUILD_BUG_ON(OVS_KEY_ATTR_TUNNEL_INFO != 22); | ||
| 261 | |||
| 262 | return nla_total_size(4) /* OVS_KEY_ATTR_PRIORITY */ | ||
| 263 | + nla_total_size(0) /* OVS_KEY_ATTR_TUNNEL */ | ||
| 264 | + nla_total_size(8) /* OVS_TUNNEL_KEY_ATTR_ID */ | ||
| 265 | + nla_total_size(4) /* OVS_TUNNEL_KEY_ATTR_IPV4_SRC */ | ||
| 266 | + nla_total_size(4) /* OVS_TUNNEL_KEY_ATTR_IPV4_DST */ | ||
| 267 | + nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TOS */ | ||
| 268 | + nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TTL */ | ||
| 269 | + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */ | ||
| 270 | + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_CSUM */ | ||
| 271 | + nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_OAM */ | ||
| 272 | + nla_total_size(256) /* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS */ | ||
| 273 | + nla_total_size(4) /* OVS_KEY_ATTR_IN_PORT */ | ||
| 274 | + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */ | ||
| 275 | + nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */ | ||
| 276 | + nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */ | ||
| 277 | + nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */ | ||
| 278 | + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ | ||
| 279 | + nla_total_size(4) /* OVS_KEY_ATTR_VLAN */ | ||
| 280 | + nla_total_size(0) /* OVS_KEY_ATTR_ENCAP */ | ||
| 281 | + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ | ||
| 282 | + nla_total_size(40) /* OVS_KEY_ATTR_IPV6 */ | ||
| 283 | + nla_total_size(2) /* OVS_KEY_ATTR_ICMPV6 */ | ||
| 284 | + nla_total_size(28); /* OVS_KEY_ATTR_ND */ | ||
| 285 | } | ||
| 286 | |||
| 255 | /* The size of the argument for each %OVS_KEY_ATTR_* Netlink attribute. */ | 287 | /* The size of the argument for each %OVS_KEY_ATTR_* Netlink attribute. */ |
| 256 | static const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = { | 288 | static const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = { |
| 257 | [OVS_KEY_ATTR_ENCAP] = -1, | 289 | [OVS_KEY_ATTR_ENCAP] = -1, |
diff --git a/net/openvswitch/flow_netlink.h b/net/openvswitch/flow_netlink.h index 6355b1d01329..4f0370646bc6 100644 --- a/net/openvswitch/flow_netlink.h +++ b/net/openvswitch/flow_netlink.h | |||
| @@ -37,6 +37,8 @@ | |||
| 37 | 37 | ||
| 38 | #include "flow.h" | 38 | #include "flow.h" |
| 39 | 39 | ||
| 40 | size_t ovs_key_attr_size(void); | ||
| 41 | |||
| 40 | void ovs_match_init(struct sw_flow_match *match, | 42 | void ovs_match_init(struct sw_flow_match *match, |
| 41 | struct sw_flow_key *key, struct sw_flow_mask *mask); | 43 | struct sw_flow_key *key, struct sw_flow_mask *mask); |
| 42 | 44 | ||
