2 * Copyright (c) 2015 Nicira, Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
14 #include <linux/module.h>
15 #include <linux/openvswitch.h>
17 #include <net/netfilter/nf_conntrack_core.h>
18 #include <net/netfilter/nf_conntrack_helper.h>
19 #include <net/netfilter/nf_conntrack_labels.h>
20 #include <net/netfilter/nf_conntrack_zones.h>
21 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
24 #include "conntrack.h"
26 #include "flow_netlink.h"
28 struct ovs_ct_len_tbl {
33 /* Metadata mark for masked write to conntrack mark */
39 /* Metadata label for masked write to conntrack label. */
41 struct ovs_key_ct_labels value;
42 struct ovs_key_ct_labels mask;
45 /* Conntrack action context for execution. */
46 struct ovs_conntrack_info {
47 struct nf_conntrack_helper *helper;
48 struct nf_conntrack_zone zone;
53 struct md_labels labels;
56 static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info);
58 static u16 key_to_nfproto(const struct sw_flow_key *key)
60 switch (ntohs(key->eth.type)) {
66 return NFPROTO_UNSPEC;
70 /* Map SKB connection state into the values used by flow definition. */
71 static u8 ovs_ct_get_state(enum ip_conntrack_info ctinfo)
73 u8 ct_state = OVS_CS_F_TRACKED;
76 case IP_CT_ESTABLISHED_REPLY:
77 case IP_CT_RELATED_REPLY:
78 ct_state |= OVS_CS_F_REPLY_DIR;
85 case IP_CT_ESTABLISHED:
86 case IP_CT_ESTABLISHED_REPLY:
87 ct_state |= OVS_CS_F_ESTABLISHED;
90 case IP_CT_RELATED_REPLY:
91 ct_state |= OVS_CS_F_RELATED;
94 ct_state |= OVS_CS_F_NEW;
103 static u32 ovs_ct_get_mark(const struct nf_conn *ct)
105 #if IS_ENABLED(CONFIG_NF_CONNTRACK_MARK)
106 return ct ? ct->mark : 0;
112 static void ovs_ct_get_labels(const struct nf_conn *ct,
113 struct ovs_key_ct_labels *labels)
115 struct nf_conn_labels *cl = ct ? nf_ct_labels_find(ct) : NULL;
118 size_t len = cl->words * sizeof(long);
120 if (len > OVS_CT_LABELS_LEN)
121 len = OVS_CT_LABELS_LEN;
122 else if (len < OVS_CT_LABELS_LEN)
123 memset(labels, 0, OVS_CT_LABELS_LEN);
124 memcpy(labels, cl->bits, len);
126 memset(labels, 0, OVS_CT_LABELS_LEN);
130 static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state,
131 const struct nf_conntrack_zone *zone,
132 const struct nf_conn *ct)
134 key->ct.state = state;
135 key->ct.zone = zone->id;
136 key->ct.mark = ovs_ct_get_mark(ct);
137 ovs_ct_get_labels(ct, &key->ct.labels);
140 /* Update 'key' based on skb->nfct. If 'post_ct' is true, then OVS has
141 * previously sent the packet to conntrack via the ct action.
143 static void ovs_ct_update_key(const struct sk_buff *skb,
144 const struct ovs_conntrack_info *info,
145 struct sw_flow_key *key, bool post_ct)
147 const struct nf_conntrack_zone *zone = &nf_ct_zone_dflt;
148 enum ip_conntrack_info ctinfo;
152 ct = nf_ct_get(skb, &ctinfo);
154 state = ovs_ct_get_state(ctinfo);
155 /* All unconfirmed entries are NEW connections. */
156 if (!nf_ct_is_confirmed(ct))
157 state |= OVS_CS_F_NEW;
158 /* OVS persists the related flag for the duration of the
162 state |= OVS_CS_F_RELATED;
163 zone = nf_ct_zone(ct);
164 } else if (post_ct) {
165 state = OVS_CS_F_TRACKED | OVS_CS_F_INVALID;
169 __ovs_ct_update_key(key, state, zone, ct);
172 /* This is called to initialize CT key fields possibly coming in from the local
175 void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key)
177 ovs_ct_update_key(skb, NULL, key, false);
180 int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb)
182 if (nla_put_u32(skb, OVS_KEY_ATTR_CT_STATE, key->ct.state))
185 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
186 nla_put_u16(skb, OVS_KEY_ATTR_CT_ZONE, key->ct.zone))
189 if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) &&
190 nla_put_u32(skb, OVS_KEY_ATTR_CT_MARK, key->ct.mark))
193 if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
194 nla_put(skb, OVS_KEY_ATTR_CT_LABELS, sizeof(key->ct.labels),
201 static int ovs_ct_set_mark(struct sk_buff *skb, struct sw_flow_key *key,
202 u32 ct_mark, u32 mask)
204 #if IS_ENABLED(CONFIG_NF_CONNTRACK_MARK)
205 enum ip_conntrack_info ctinfo;
209 /* The connection could be invalid, in which case set_mark is no-op. */
210 ct = nf_ct_get(skb, &ctinfo);
214 new_mark = ct_mark | (ct->mark & ~(mask));
215 if (ct->mark != new_mark) {
217 nf_conntrack_event_cache(IPCT_MARK, ct);
218 key->ct.mark = new_mark;
227 static int ovs_ct_set_labels(struct sk_buff *skb, struct sw_flow_key *key,
228 const struct ovs_key_ct_labels *labels,
229 const struct ovs_key_ct_labels *mask)
231 enum ip_conntrack_info ctinfo;
232 struct nf_conn_labels *cl;
236 /* The connection could be invalid, in which case set_label is no-op.*/
237 ct = nf_ct_get(skb, &ctinfo);
241 cl = nf_ct_labels_find(ct);
243 nf_ct_labels_ext_add(ct);
244 cl = nf_ct_labels_find(ct);
246 if (!cl || cl->words * sizeof(long) < OVS_CT_LABELS_LEN)
249 err = nf_connlabels_replace(ct, (u32 *)labels, (u32 *)mask,
250 OVS_CT_LABELS_LEN / sizeof(u32));
254 ovs_ct_get_labels(ct, &key->ct.labels);
258 /* 'skb' should already be pulled to nh_ofs. */
259 static int ovs_ct_helper(struct sk_buff *skb, u16 proto)
261 const struct nf_conntrack_helper *helper;
262 const struct nf_conn_help *help;
263 enum ip_conntrack_info ctinfo;
264 unsigned int protoff;
267 ct = nf_ct_get(skb, &ctinfo);
268 if (!ct || ctinfo == IP_CT_RELATED_REPLY)
271 help = nfct_help(ct);
275 helper = rcu_dereference(help->helper);
281 protoff = ip_hdrlen(skb);
284 u8 nexthdr = ipv6_hdr(skb)->nexthdr;
288 ofs = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
290 if (ofs < 0 || (frag_off & htons(~0x7)) != 0) {
291 pr_debug("proto header not found\n");
298 WARN_ONCE(1, "helper invoked on non-IP family!");
302 return helper->help(skb, protoff, ct, ctinfo);
305 /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero
306 * value if 'skb' is freed.
308 static int handle_fragments(struct net *net, struct sw_flow_key *key,
309 u16 zone, struct sk_buff *skb)
311 struct ovs_skb_cb ovs_cb = *OVS_CB(skb);
314 if (key->eth.type == htons(ETH_P_IP)) {
315 enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
317 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
318 err = ip_defrag(net, skb, user);
322 ovs_cb.mru = IPCB(skb)->frag_max_size;
323 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
324 } else if (key->eth.type == htons(ETH_P_IPV6)) {
325 enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone;
327 memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
328 err = nf_ct_frag6_gather(net, skb, user);
332 key->ip.proto = ipv6_hdr(skb)->nexthdr;
333 ovs_cb.mru = IP6CB(skb)->frag_max_size;
337 return -EPFNOSUPPORT;
340 key->ip.frag = OVS_FRAG_TYPE_NONE;
343 *OVS_CB(skb) = ovs_cb;
348 static struct nf_conntrack_expect *
349 ovs_ct_expect_find(struct net *net, const struct nf_conntrack_zone *zone,
350 u16 proto, const struct sk_buff *skb)
352 struct nf_conntrack_tuple tuple;
354 if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), proto, net, &tuple))
356 return __nf_ct_expect_find(net, zone, &tuple);
359 /* This replicates logic from nf_conntrack_core.c that is not exported. */
360 static enum ip_conntrack_info
361 ovs_ct_get_info(const struct nf_conntrack_tuple_hash *h)
363 const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);
365 if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
366 return IP_CT_ESTABLISHED_REPLY;
367 /* Once we've had two way comms, always ESTABLISHED. */
368 if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status))
369 return IP_CT_ESTABLISHED;
370 if (test_bit(IPS_EXPECTED_BIT, &ct->status))
371 return IP_CT_RELATED;
375 /* Find an existing connection which this packet belongs to without
376 * re-attributing statistics or modifying the connection state. This allows an
377 * skb->nfct lost due to an upcall to be recovered during actions execution.
379 * Must be called with rcu_read_lock.
381 * On success, populates skb->nfct and skb->nfctinfo, and returns the
382 * connection. Returns NULL if there is no existing entry.
384 static struct nf_conn *
385 ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone,
386 u8 l3num, struct sk_buff *skb)
388 struct nf_conntrack_l3proto *l3proto;
389 struct nf_conntrack_l4proto *l4proto;
390 struct nf_conntrack_tuple tuple;
391 struct nf_conntrack_tuple_hash *h;
392 enum ip_conntrack_info ctinfo;
394 unsigned int dataoff;
397 l3proto = __nf_ct_l3proto_find(l3num);
399 pr_debug("ovs_ct_find_existing: Can't get l3proto\n");
402 if (l3proto->get_l4proto(skb, skb_network_offset(skb), &dataoff,
404 pr_debug("ovs_ct_find_existing: Can't get protonum\n");
407 l4proto = __nf_ct_l4proto_find(l3num, protonum);
409 pr_debug("ovs_ct_find_existing: Can't get l4proto\n");
412 if (!nf_ct_get_tuple(skb, skb_network_offset(skb), dataoff, l3num,
413 protonum, net, &tuple, l3proto, l4proto)) {
414 pr_debug("ovs_ct_find_existing: Can't get tuple\n");
418 /* look for tuple match */
419 h = nf_conntrack_find_get(net, zone, &tuple);
421 return NULL; /* Not found. */
423 ct = nf_ct_tuplehash_to_ctrack(h);
425 ctinfo = ovs_ct_get_info(h);
426 if (ctinfo == IP_CT_NEW) {
427 /* This should not happen. */
428 WARN_ONCE(1, "ovs_ct_find_existing: new packet for %p\n", ct);
430 skb->nfct = &ct->ct_general;
431 skb->nfctinfo = ctinfo;
435 /* Determine whether skb->nfct is equal to the result of conntrack lookup. */
436 static bool skb_nfct_cached(struct net *net,
437 const struct sw_flow_key *key,
438 const struct ovs_conntrack_info *info,
441 enum ip_conntrack_info ctinfo;
444 ct = nf_ct_get(skb, &ctinfo);
445 /* If no ct, check if we have evidence that an existing conntrack entry
446 * might be found for this skb. This happens when we lose a skb->nfct
447 * due to an upcall. If the connection was not confirmed, it is not
448 * cached and needs to be run through conntrack again.
450 if (!ct && key->ct.state & OVS_CS_F_TRACKED &&
451 !(key->ct.state & OVS_CS_F_INVALID) &&
452 key->ct.zone == info->zone.id)
453 ct = ovs_ct_find_existing(net, &info->zone, info->family, skb);
456 if (!net_eq(net, read_pnet(&ct->ct_net)))
458 if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct)))
461 struct nf_conn_help *help;
463 help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
464 if (help && rcu_access_pointer(help->helper) != info->helper)
471 /* Pass 'skb' through conntrack in 'net', using zone configured in 'info', if
472 * not done already. Update key with new CT state after passing the packet
474 * Note that if the packet is deemed invalid by conntrack, skb->nfct will be
475 * set to NULL and 0 will be returned.
477 static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
478 const struct ovs_conntrack_info *info,
481 /* If we are recirculating packets to match on conntrack fields and
482 * committing with a separate conntrack action, then we don't need to
483 * actually run the packet through conntrack twice unless it's for a
486 bool cached = skb_nfct_cached(net, key, info, skb);
487 enum ip_conntrack_info ctinfo;
491 struct nf_conn *tmpl = info->ct;
494 /* Associate skb with specified zone. */
497 nf_conntrack_put(skb->nfct);
498 nf_conntrack_get(&tmpl->ct_general);
499 skb->nfct = &tmpl->ct_general;
500 skb->nfctinfo = IP_CT_NEW;
503 /* Repeat if requested, see nf_iterate(). */
505 err = nf_conntrack_in(net, info->family,
506 NF_INET_PRE_ROUTING, skb);
507 } while (err == NF_REPEAT);
509 if (err != NF_ACCEPT)
512 ovs_ct_update_key(skb, info, key, true);
515 /* Call the helper only if:
516 * - nf_conntrack_in() was executed above ("!cached") for a confirmed
518 * - When committing an unconfirmed connection.
520 ct = nf_ct_get(skb, &ctinfo);
521 if (ct && (nf_ct_is_confirmed(ct) ? !cached : info->commit) &&
522 ovs_ct_helper(skb, info->family) != NF_ACCEPT) {
523 WARN_ONCE(1, "helper rejected packet");
530 /* Lookup connection and read fields into key. */
531 static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
532 const struct ovs_conntrack_info *info,
535 struct nf_conntrack_expect *exp;
537 /* If we pass an expected packet through nf_conntrack_in() the
538 * expectation is typically removed, but the packet could still be
539 * lost in upcall processing. To prevent this from happening we
540 * perform an explicit expectation lookup. Expected connections are
541 * always new, and will be passed through conntrack only when they are
542 * committed, as it is OK to remove the expectation at that time.
544 exp = ovs_ct_expect_find(net, &info->zone, info->family, skb);
548 state = OVS_CS_F_TRACKED | OVS_CS_F_NEW | OVS_CS_F_RELATED;
549 __ovs_ct_update_key(key, state, &info->zone, exp->master);
553 err = __ovs_ct_lookup(net, key, info, skb);
561 /* Lookup connection and confirm if unconfirmed. */
562 static int ovs_ct_commit(struct net *net, struct sw_flow_key *key,
563 const struct ovs_conntrack_info *info,
568 err = __ovs_ct_lookup(net, key, info, skb);
571 /* This is a no-op if the connection has already been confirmed. */
572 if (nf_conntrack_confirm(skb) != NF_ACCEPT)
578 static bool labels_nonzero(const struct ovs_key_ct_labels *labels)
582 for (i = 0; i < sizeof(*labels); i++)
583 if (labels->ct_labels[i])
589 /* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero
590 * value if 'skb' is freed.
592 int ovs_ct_execute(struct net *net, struct sk_buff *skb,
593 struct sw_flow_key *key,
594 const struct ovs_conntrack_info *info)
599 /* The conntrack module expects to be working at L3. */
600 nh_ofs = skb_network_offset(skb);
601 skb_pull(skb, nh_ofs);
603 if (key->ip.frag != OVS_FRAG_TYPE_NONE) {
604 err = handle_fragments(net, key, info->zone.id, skb);
610 err = ovs_ct_commit(net, key, info, skb);
612 err = ovs_ct_lookup(net, key, info, skb);
616 if (info->mark.mask) {
617 err = ovs_ct_set_mark(skb, key, info->mark.value,
622 if (labels_nonzero(&info->labels.mask))
623 err = ovs_ct_set_labels(skb, key, &info->labels.value,
626 skb_push(skb, nh_ofs);
632 static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name,
633 const struct sw_flow_key *key, bool log)
635 struct nf_conntrack_helper *helper;
636 struct nf_conn_help *help;
638 helper = nf_conntrack_helper_try_module_get(name, info->family,
641 OVS_NLERR(log, "Unknown helper \"%s\"", name);
645 help = nf_ct_helper_ext_add(info->ct, helper, GFP_KERNEL);
647 module_put(helper->me);
651 rcu_assign_pointer(help->helper, helper);
652 info->helper = helper;
656 static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = {
657 [OVS_CT_ATTR_COMMIT] = { .minlen = 0, .maxlen = 0 },
658 [OVS_CT_ATTR_ZONE] = { .minlen = sizeof(u16),
659 .maxlen = sizeof(u16) },
660 [OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark),
661 .maxlen = sizeof(struct md_mark) },
662 [OVS_CT_ATTR_LABELS] = { .minlen = sizeof(struct md_labels),
663 .maxlen = sizeof(struct md_labels) },
664 [OVS_CT_ATTR_HELPER] = { .minlen = 1,
665 .maxlen = NF_CT_HELPER_NAME_LEN }
668 static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
669 const char **helper, bool log)
674 nla_for_each_nested(a, attr, rem) {
675 int type = nla_type(a);
676 int maxlen = ovs_ct_attr_lens[type].maxlen;
677 int minlen = ovs_ct_attr_lens[type].minlen;
679 if (type > OVS_CT_ATTR_MAX) {
681 "Unknown conntrack attr (type=%d, max=%d)",
682 type, OVS_CT_ATTR_MAX);
685 if (nla_len(a) < minlen || nla_len(a) > maxlen) {
687 "Conntrack attr type has unexpected length (type=%d, length=%d, expected=%d)",
688 type, nla_len(a), maxlen);
693 case OVS_CT_ATTR_COMMIT:
696 #ifdef CONFIG_NF_CONNTRACK_ZONES
697 case OVS_CT_ATTR_ZONE:
698 info->zone.id = nla_get_u16(a);
701 #ifdef CONFIG_NF_CONNTRACK_MARK
702 case OVS_CT_ATTR_MARK: {
703 struct md_mark *mark = nla_data(a);
706 OVS_NLERR(log, "ct_mark mask cannot be 0");
713 #ifdef CONFIG_NF_CONNTRACK_LABELS
714 case OVS_CT_ATTR_LABELS: {
715 struct md_labels *labels = nla_data(a);
717 if (!labels_nonzero(&labels->mask)) {
718 OVS_NLERR(log, "ct_labels mask cannot be 0");
721 info->labels = *labels;
725 case OVS_CT_ATTR_HELPER:
726 *helper = nla_data(a);
727 if (!memchr(*helper, '\0', nla_len(a))) {
728 OVS_NLERR(log, "Invalid conntrack helper");
733 OVS_NLERR(log, "Unknown conntrack attr (%d)",
740 OVS_NLERR(log, "Conntrack attr has %d unknown bytes", rem);
747 bool ovs_ct_verify(struct net *net, enum ovs_key_attr attr)
749 if (attr == OVS_KEY_ATTR_CT_STATE)
751 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
752 attr == OVS_KEY_ATTR_CT_ZONE)
754 if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) &&
755 attr == OVS_KEY_ATTR_CT_MARK)
757 if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
758 attr == OVS_KEY_ATTR_CT_LABELS) {
759 struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
761 return ovs_net->xt_label;
767 int ovs_ct_copy_action(struct net *net, const struct nlattr *attr,
768 const struct sw_flow_key *key,
769 struct sw_flow_actions **sfa, bool log)
771 struct ovs_conntrack_info ct_info;
772 const char *helper = NULL;
776 family = key_to_nfproto(key);
777 if (family == NFPROTO_UNSPEC) {
778 OVS_NLERR(log, "ct family unspecified");
782 memset(&ct_info, 0, sizeof(ct_info));
783 ct_info.family = family;
785 nf_ct_zone_init(&ct_info.zone, NF_CT_DEFAULT_ZONE_ID,
786 NF_CT_DEFAULT_ZONE_DIR, 0);
788 err = parse_ct(attr, &ct_info, &helper, log);
792 /* Set up template for tracking connections in specific zones. */
793 ct_info.ct = nf_ct_tmpl_alloc(net, &ct_info.zone, GFP_KERNEL);
795 OVS_NLERR(log, "Failed to allocate conntrack template");
799 __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status);
800 nf_conntrack_get(&ct_info.ct->ct_general);
803 err = ovs_ct_add_helper(&ct_info, helper, key, log);
808 err = ovs_nla_add_action(sfa, OVS_ACTION_ATTR_CT, &ct_info,
809 sizeof(ct_info), log);
815 __ovs_ct_free_action(&ct_info);
819 int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info,
822 struct nlattr *start;
824 start = nla_nest_start(skb, OVS_ACTION_ATTR_CT);
828 if (ct_info->commit && nla_put_flag(skb, OVS_CT_ATTR_COMMIT))
830 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
831 nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id))
833 if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) && ct_info->mark.mask &&
834 nla_put(skb, OVS_CT_ATTR_MARK, sizeof(ct_info->mark),
837 if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
838 labels_nonzero(&ct_info->labels.mask) &&
839 nla_put(skb, OVS_CT_ATTR_LABELS, sizeof(ct_info->labels),
842 if (ct_info->helper) {
843 if (nla_put_string(skb, OVS_CT_ATTR_HELPER,
844 ct_info->helper->name))
848 nla_nest_end(skb, start);
853 void ovs_ct_free_action(const struct nlattr *a)
855 struct ovs_conntrack_info *ct_info = nla_data(a);
857 __ovs_ct_free_action(ct_info);
860 static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info)
863 module_put(ct_info->helper->me);
865 nf_ct_put(ct_info->ct);
868 void ovs_ct_init(struct net *net)
870 unsigned int n_bits = sizeof(struct ovs_key_ct_labels) * BITS_PER_BYTE;
871 struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
873 if (nf_connlabels_get(net, n_bits)) {
874 ovs_net->xt_label = false;
875 OVS_NLERR(true, "Failed to set connlabel length");
877 ovs_net->xt_label = true;
881 void ovs_ct_exit(struct net *net)
883 struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
885 if (ovs_net->xt_label)
886 nf_connlabels_put(net);