|
|
@@ -129,22 +129,20 @@ static u32 ovs_ct_get_mark(const struct nf_conn *ct)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+/* Guard against conntrack labels max size shrinking below 128 bits. */
|
|
|
+#if NF_CT_LABELS_MAX_SIZE < 16
|
|
|
+#error NF_CT_LABELS_MAX_SIZE must be at least 16 bytes
|
|
|
+#endif
|
|
|
+
|
|
|
static void ovs_ct_get_labels(const struct nf_conn *ct,
|
|
|
struct ovs_key_ct_labels *labels)
|
|
|
{
|
|
|
struct nf_conn_labels *cl = ct ? nf_ct_labels_find(ct) : NULL;
|
|
|
|
|
|
- if (cl) {
|
|
|
- size_t len = sizeof(cl->bits);
|
|
|
-
|
|
|
- if (len > OVS_CT_LABELS_LEN)
|
|
|
- len = OVS_CT_LABELS_LEN;
|
|
|
- else if (len < OVS_CT_LABELS_LEN)
|
|
|
- memset(labels, 0, OVS_CT_LABELS_LEN);
|
|
|
- memcpy(labels, cl->bits, len);
|
|
|
- } else {
|
|
|
+ if (cl)
|
|
|
+ memcpy(labels, cl->bits, OVS_CT_LABELS_LEN);
|
|
|
+ else
|
|
|
memset(labels, 0, OVS_CT_LABELS_LEN);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state,
|
|
|
@@ -274,7 +272,7 @@ static int ovs_ct_set_labels(struct sk_buff *skb, struct sw_flow_key *key,
|
|
|
nf_ct_labels_ext_add(ct);
|
|
|
cl = nf_ct_labels_find(ct);
|
|
|
}
|
|
|
- if (!cl || sizeof(cl->bits) < OVS_CT_LABELS_LEN)
|
|
|
+ if (!cl)
|
|
|
return -ENOSPC;
|
|
|
|
|
|
if (nf_ct_is_confirmed(ct)) {
|