Skip to content

Commit 33db412

Browse files
joestringerdavem330
authored andcommitted
openvswitch: Rename LABEL->LABELS
Conntrack LABELS (plural) are exposed by conntrack; rename the OVS name for these to be consistent with conntrack. Fixes: c2ac667 "openvswitch: Allow matching on conntrack label" 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>
1 parent e9193d6 commit 33db412

File tree

6 files changed

+55
-55
lines changed

6 files changed

+55
-55
lines changed

include/uapi/linux/openvswitch.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ enum ovs_key_attr {
326326
OVS_KEY_ATTR_CT_STATE, /* u8 bitmask of OVS_CS_F_* */
327327
OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */
328328
OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */
329-
OVS_KEY_ATTR_CT_LABEL, /* 16-octet connection tracking label */
329+
OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */
330330

331331
#ifdef __KERNEL__
332332
OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */
@@ -439,9 +439,9 @@ struct ovs_key_nd {
439439
__u8 nd_tll[ETH_ALEN];
440440
};
441441

442-
#define OVS_CT_LABEL_LEN 16
443-
struct ovs_key_ct_label {
444-
__u8 ct_label[OVS_CT_LABEL_LEN];
442+
#define OVS_CT_LABELS_LEN 16
443+
struct ovs_key_ct_labels {
444+
__u8 ct_labels[OVS_CT_LABELS_LEN];
445445
};
446446

447447
/* OVS_KEY_ATTR_CT_STATE flags */
@@ -623,7 +623,7 @@ struct ovs_action_hash {
623623
* @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the
624624
* mask, the corresponding bit in the value is copied to the connection
625625
* tracking mark field in the connection.
626-
* @OVS_CT_ATTR_LABEL: %OVS_CT_LABEL_LEN value followed by %OVS_CT_LABEL_LEN
626+
* @OVS_CT_ATTR_LABEL: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN
627627
* mask. For each bit set in the mask, the corresponding bit in the value is
628628
* copied to the connection tracking label field in the connection.
629629
* @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG.
@@ -633,7 +633,7 @@ enum ovs_ct_attr {
633633
OVS_CT_ATTR_FLAGS, /* u8 bitmask of OVS_CT_F_*. */
634634
OVS_CT_ATTR_ZONE, /* u16 zone id. */
635635
OVS_CT_ATTR_MARK, /* mark to associate with this connection. */
636-
OVS_CT_ATTR_LABEL, /* label to associate with this connection. */
636+
OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */
637637
OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of
638638
related connections. */
639639
__OVS_CT_ATTR_MAX

net/openvswitch/actions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ static int execute_masked_set_action(struct sk_buff *skb,
968968
case OVS_KEY_ATTR_CT_STATE:
969969
case OVS_KEY_ATTR_CT_ZONE:
970970
case OVS_KEY_ATTR_CT_MARK:
971-
case OVS_KEY_ATTR_CT_LABEL:
971+
case OVS_KEY_ATTR_CT_LABELS:
972972
err = -EINVAL;
973973
break;
974974
}

net/openvswitch/conntrack.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ struct md_mark {
3737
};
3838

3939
/* Metadata label for masked write to conntrack label. */
40-
struct md_label {
41-
struct ovs_key_ct_label value;
42-
struct ovs_key_ct_label mask;
40+
struct md_labels {
41+
struct ovs_key_ct_labels value;
42+
struct ovs_key_ct_labels mask;
4343
};
4444

4545
/* Conntrack action context for execution. */
@@ -50,7 +50,7 @@ struct ovs_conntrack_info {
5050
u32 flags;
5151
u16 family;
5252
struct md_mark mark;
53-
struct md_label label;
53+
struct md_labels labels;
5454
};
5555

5656
static u16 key_to_nfproto(const struct sw_flow_key *key)
@@ -109,21 +109,21 @@ static u32 ovs_ct_get_mark(const struct nf_conn *ct)
109109
#endif
110110
}
111111

112-
static void ovs_ct_get_label(const struct nf_conn *ct,
113-
struct ovs_key_ct_label *label)
112+
static void ovs_ct_get_labels(const struct nf_conn *ct,
113+
struct ovs_key_ct_labels *labels)
114114
{
115115
struct nf_conn_labels *cl = ct ? nf_ct_labels_find(ct) : NULL;
116116

117117
if (cl) {
118118
size_t len = cl->words * sizeof(long);
119119

120-
if (len > OVS_CT_LABEL_LEN)
121-
len = OVS_CT_LABEL_LEN;
122-
else if (len < OVS_CT_LABEL_LEN)
123-
memset(label, 0, OVS_CT_LABEL_LEN);
124-
memcpy(label, cl->bits, len);
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);
125125
} else {
126-
memset(label, 0, OVS_CT_LABEL_LEN);
126+
memset(labels, 0, OVS_CT_LABELS_LEN);
127127
}
128128
}
129129

@@ -134,7 +134,7 @@ static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state,
134134
key->ct.state = state;
135135
key->ct.zone = zone->id;
136136
key->ct.mark = ovs_ct_get_mark(ct);
137-
ovs_ct_get_label(ct, &key->ct.label);
137+
ovs_ct_get_labels(ct, &key->ct.labels);
138138
}
139139

140140
/* Update 'key' based on skb->nfct. If 'post_ct' is true, then OVS has
@@ -179,8 +179,8 @@ int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb)
179179
return -EMSGSIZE;
180180

181181
if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
182-
nla_put(skb, OVS_KEY_ATTR_CT_LABEL, sizeof(key->ct.label),
183-
&key->ct.label))
182+
nla_put(skb, OVS_KEY_ATTR_CT_LABELS, sizeof(key->ct.labels),
183+
&key->ct.labels))
184184
return -EMSGSIZE;
185185

186186
return 0;
@@ -213,9 +213,9 @@ static int ovs_ct_set_mark(struct sk_buff *skb, struct sw_flow_key *key,
213213
#endif
214214
}
215215

216-
static int ovs_ct_set_label(struct sk_buff *skb, struct sw_flow_key *key,
217-
const struct ovs_key_ct_label *label,
218-
const struct ovs_key_ct_label *mask)
216+
static int ovs_ct_set_labels(struct sk_buff *skb, struct sw_flow_key *key,
217+
const struct ovs_key_ct_labels *labels,
218+
const struct ovs_key_ct_labels *mask)
219219
{
220220
enum ip_conntrack_info ctinfo;
221221
struct nf_conn_labels *cl;
@@ -235,15 +235,15 @@ static int ovs_ct_set_label(struct sk_buff *skb, struct sw_flow_key *key,
235235
nf_ct_labels_ext_add(ct);
236236
cl = nf_ct_labels_find(ct);
237237
}
238-
if (!cl || cl->words * sizeof(long) < OVS_CT_LABEL_LEN)
238+
if (!cl || cl->words * sizeof(long) < OVS_CT_LABELS_LEN)
239239
return -ENOSPC;
240240

241-
err = nf_connlabels_replace(ct, (u32 *)label, (u32 *)mask,
242-
OVS_CT_LABEL_LEN / sizeof(u32));
241+
err = nf_connlabels_replace(ct, (u32 *)labels, (u32 *)mask,
242+
OVS_CT_LABELS_LEN / sizeof(u32));
243243
if (err)
244244
return err;
245245

246-
ovs_ct_get_label(ct, &key->ct.label);
246+
ovs_ct_get_labels(ct, &key->ct.labels);
247247
return 0;
248248
}
249249

@@ -465,12 +465,12 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key,
465465
return 0;
466466
}
467467

468-
static bool label_nonzero(const struct ovs_key_ct_label *label)
468+
static bool labels_nonzero(const struct ovs_key_ct_labels *labels)
469469
{
470470
size_t i;
471471

472-
for (i = 0; i < sizeof(*label); i++)
473-
if (label->ct_label[i])
472+
for (i = 0; i < sizeof(*labels); i++)
473+
if (labels->ct_labels[i])
474474
return true;
475475

476476
return false;
@@ -506,9 +506,9 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,
506506
if (err)
507507
goto err;
508508
}
509-
if (label_nonzero(&info->label.mask))
510-
err = ovs_ct_set_label(skb, key, &info->label.value,
511-
&info->label.mask);
509+
if (labels_nonzero(&info->labels.mask))
510+
err = ovs_ct_set_labels(skb, key, &info->labels.value,
511+
&info->labels.mask);
512512
err:
513513
skb_push(skb, nh_ofs);
514514
return err;
@@ -545,8 +545,8 @@ static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = {
545545
.maxlen = sizeof(u16) },
546546
[OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark),
547547
.maxlen = sizeof(struct md_mark) },
548-
[OVS_CT_ATTR_LABEL] = { .minlen = sizeof(struct md_label),
549-
.maxlen = sizeof(struct md_label) },
548+
[OVS_CT_ATTR_LABELS] = { .minlen = sizeof(struct md_labels),
549+
.maxlen = sizeof(struct md_labels) },
550550
[OVS_CT_ATTR_HELPER] = { .minlen = 1,
551551
.maxlen = NF_CT_HELPER_NAME_LEN }
552552
};
@@ -593,10 +593,10 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
593593
}
594594
#endif
595595
#ifdef CONFIG_NF_CONNTRACK_LABELS
596-
case OVS_CT_ATTR_LABEL: {
597-
struct md_label *label = nla_data(a);
596+
case OVS_CT_ATTR_LABELS: {
597+
struct md_labels *labels = nla_data(a);
598598

599-
info->label = *label;
599+
info->labels = *labels;
600600
break;
601601
}
602602
#endif
@@ -633,7 +633,7 @@ bool ovs_ct_verify(struct net *net, enum ovs_key_attr attr)
633633
attr == OVS_KEY_ATTR_CT_MARK)
634634
return true;
635635
if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
636-
attr == OVS_KEY_ATTR_CT_LABEL) {
636+
attr == OVS_KEY_ATTR_CT_LABELS) {
637637
struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
638638

639639
return ovs_net->xt_label;
@@ -711,8 +711,8 @@ int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info,
711711
&ct_info->mark))
712712
return -EMSGSIZE;
713713
if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
714-
nla_put(skb, OVS_CT_ATTR_LABEL, sizeof(ct_info->label),
715-
&ct_info->label))
714+
nla_put(skb, OVS_CT_ATTR_LABELS, sizeof(ct_info->labels),
715+
&ct_info->labels))
716716
return -EMSGSIZE;
717717
if (ct_info->helper) {
718718
if (nla_put_string(skb, OVS_CT_ATTR_HELPER,
@@ -737,7 +737,7 @@ void ovs_ct_free_action(const struct nlattr *a)
737737

738738
void ovs_ct_init(struct net *net)
739739
{
740-
unsigned int n_bits = sizeof(struct ovs_key_ct_label) * BITS_PER_BYTE;
740+
unsigned int n_bits = sizeof(struct ovs_key_ct_labels) * BITS_PER_BYTE;
741741
struct ovs_net *ovs_net = net_generic(net, ovs_net_id);
742742

743743
if (nf_connlabels_get(net, n_bits)) {

net/openvswitch/conntrack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static inline void ovs_ct_fill_key(const struct sk_buff *skb,
7272
key->ct.state = 0;
7373
key->ct.zone = 0;
7474
key->ct.mark = 0;
75-
memset(&key->ct.label, 0, sizeof(key->ct.label));
75+
memset(&key->ct.labels, 0, sizeof(key->ct.labels));
7676
}
7777

7878
static inline int ovs_ct_put_key(const struct sw_flow_key *key,

net/openvswitch/flow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct sw_flow_key {
116116
u16 zone;
117117
u32 mark;
118118
u8 state;
119-
struct ovs_key_ct_label label;
119+
struct ovs_key_ct_labels labels;
120120
} ct;
121121

122122
} __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */

net/openvswitch/flow_netlink.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ size_t ovs_key_attr_size(void)
294294
+ nla_total_size(1) /* OVS_KEY_ATTR_CT_STATE */
295295
+ nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */
296296
+ nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */
297-
+ nla_total_size(16) /* OVS_KEY_ATTR_CT_LABEL */
297+
+ nla_total_size(16) /* OVS_KEY_ATTR_CT_LABELS */
298298
+ nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */
299299
+ nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */
300300
+ nla_total_size(4) /* OVS_KEY_ATTR_VLAN */
@@ -352,7 +352,7 @@ static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
352352
[OVS_KEY_ATTR_CT_STATE] = { .len = sizeof(u8) },
353353
[OVS_KEY_ATTR_CT_ZONE] = { .len = sizeof(u16) },
354354
[OVS_KEY_ATTR_CT_MARK] = { .len = sizeof(u32) },
355-
[OVS_KEY_ATTR_CT_LABEL] = { .len = sizeof(struct ovs_key_ct_label) },
355+
[OVS_KEY_ATTR_CT_LABELS] = { .len = sizeof(struct ovs_key_ct_labels) },
356356
};
357357

358358
static bool check_attr_len(unsigned int attr_len, unsigned int expected_len)
@@ -833,14 +833,14 @@ static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match,
833833
SW_FLOW_KEY_PUT(match, ct.mark, mark, is_mask);
834834
*attrs &= ~(1ULL << OVS_KEY_ATTR_CT_MARK);
835835
}
836-
if (*attrs & (1 << OVS_KEY_ATTR_CT_LABEL) &&
837-
ovs_ct_verify(net, OVS_KEY_ATTR_CT_LABEL)) {
838-
const struct ovs_key_ct_label *cl;
836+
if (*attrs & (1 << OVS_KEY_ATTR_CT_LABELS) &&
837+
ovs_ct_verify(net, OVS_KEY_ATTR_CT_LABELS)) {
838+
const struct ovs_key_ct_labels *cl;
839839

840-
cl = nla_data(a[OVS_KEY_ATTR_CT_LABEL]);
841-
SW_FLOW_KEY_MEMCPY(match, ct.label, cl->ct_label,
840+
cl = nla_data(a[OVS_KEY_ATTR_CT_LABELS]);
841+
SW_FLOW_KEY_MEMCPY(match, ct.labels, cl->ct_labels,
842842
sizeof(*cl), is_mask);
843-
*attrs &= ~(1ULL << OVS_KEY_ATTR_CT_LABEL);
843+
*attrs &= ~(1ULL << OVS_KEY_ATTR_CT_LABELS);
844844
}
845845
return 0;
846846
}
@@ -1973,7 +1973,7 @@ static int validate_set(const struct nlattr *a,
19731973
case OVS_KEY_ATTR_PRIORITY:
19741974
case OVS_KEY_ATTR_SKB_MARK:
19751975
case OVS_KEY_ATTR_CT_MARK:
1976-
case OVS_KEY_ATTR_CT_LABEL:
1976+
case OVS_KEY_ATTR_CT_LABELS:
19771977
case OVS_KEY_ATTR_ETHERNET:
19781978
break;
19791979

0 commit comments

Comments
 (0)