Skip to content

Commit a4cfe99

Browse files
author
Herton R. Krzesinski
committed
Merge: ovs: backorts P2 for 9.2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1932 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2163374 Signed-off-by: Antoine Tenart <atenart@redhat.com> Approved-by: Xin Long <lxin@redhat.com> Approved-by: Eelco Chaudron <echaudro@redhat.com> Approved-by: Marcelo Ricardo Leitner <mleitner@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents a96857a + b4ba873 commit a4cfe99

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

net/openvswitch/conntrack.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
794794
const struct nf_nat_range2 *range,
795795
enum nf_nat_manip_type maniptype, struct sw_flow_key *key)
796796
{
797-
int hooknum, nh_off, err = NF_ACCEPT;
798-
799-
nh_off = skb_network_offset(skb);
800-
skb_pull_rcsum(skb, nh_off);
797+
int hooknum, err = NF_ACCEPT;
801798

802799
/* See HOOK2MANIP(). */
803800
if (maniptype == NF_NAT_MANIP_SRC)
@@ -814,7 +811,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
814811
if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo,
815812
hooknum))
816813
err = NF_DROP;
817-
goto push;
814+
goto out;
818815
} else if (IS_ENABLED(CONFIG_IPV6) &&
819816
skb->protocol == htons(ETH_P_IPV6)) {
820817
__be16 frag_off;
@@ -829,7 +826,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
829826
hooknum,
830827
hdrlen))
831828
err = NF_DROP;
832-
goto push;
829+
goto out;
833830
}
834831
}
835832
/* Non-ICMP, fall thru to initialize if needed. */
@@ -847,7 +844,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
847844
? nf_nat_setup_info(ct, range, maniptype)
848845
: nf_nat_alloc_null_binding(ct, hooknum);
849846
if (err != NF_ACCEPT)
850-
goto push;
847+
goto out;
851848
}
852849
break;
853850

@@ -857,13 +854,11 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
857854

858855
default:
859856
err = NF_DROP;
860-
goto push;
857+
goto out;
861858
}
862859

863860
err = nf_nat_packet(ct, ctinfo, hooknum, skb);
864-
push:
865-
skb_push_rcsum(skb, nh_off);
866-
861+
out:
867862
/* Update the flow key if NAT successful. */
868863
if (err == NF_ACCEPT)
869864
ovs_nat_update_key(key, skb, maniptype);
@@ -880,17 +875,19 @@ static int ovs_ct_nat(struct net *net, struct sw_flow_key *key,
880875
enum nf_nat_manip_type maniptype;
881876
int err;
882877

878+
if (!(info->nat & OVS_CT_NAT))
879+
return NF_ACCEPT;
880+
883881
/* Add NAT extension if not confirmed yet. */
884882
if (!nf_ct_is_confirmed(ct) && !nf_ct_nat_ext_add(ct))
885-
return NF_ACCEPT; /* Can't NAT. */
883+
return NF_DROP; /* Can't NAT. */
886884

887885
/* Determine NAT type.
888886
* Check if the NAT type can be deduced from the tracked connection.
889887
* Make sure new expected connections (IP_CT_RELATED) are NATted only
890888
* when committing.
891889
*/
892-
if (info->nat & OVS_CT_NAT && ctinfo != IP_CT_NEW &&
893-
ct->status & IPS_NAT_MASK &&
890+
if (ctinfo != IP_CT_NEW && ct->status & IPS_NAT_MASK &&
894891
(ctinfo != IP_CT_RELATED || info->commit)) {
895892
/* NAT an established or related connection like before. */
896893
if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY)

net/openvswitch/datapath.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
947947
struct sw_flow_mask mask;
948948
struct sk_buff *reply;
949949
struct datapath *dp;
950+
struct sw_flow_key *key;
950951
struct sw_flow_actions *acts;
951952
struct sw_flow_match match;
952953
u32 ufid_flags = ovs_nla_get_ufid_flags(a[OVS_FLOW_ATTR_UFID_FLAGS]);
@@ -974,24 +975,26 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
974975
}
975976

976977
/* Extract key. */
977-
ovs_match_init(&match, &new_flow->key, false, &mask);
978+
key = kzalloc(sizeof(*key), GFP_KERNEL);
979+
if (!key) {
980+
error = -ENOMEM;
981+
goto err_kfree_key;
982+
}
983+
984+
ovs_match_init(&match, key, false, &mask);
978985
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
979986
a[OVS_FLOW_ATTR_MASK], log);
980987
if (error)
981988
goto err_kfree_flow;
982989

990+
ovs_flow_mask_key(&new_flow->key, key, true, &mask);
991+
983992
/* Extract flow identifier. */
984993
error = ovs_nla_get_identifier(&new_flow->id, a[OVS_FLOW_ATTR_UFID],
985-
&new_flow->key, log);
994+
key, log);
986995
if (error)
987996
goto err_kfree_flow;
988997

989-
/* unmasked key is needed to match when ufid is not used. */
990-
if (ovs_identifier_is_key(&new_flow->id))
991-
match.key = new_flow->id.unmasked_key;
992-
993-
ovs_flow_mask_key(&new_flow->key, &new_flow->key, true, &mask);
994-
995998
/* Validate actions. */
996999
error = ovs_nla_copy_actions(net, a[OVS_FLOW_ATTR_ACTIONS],
9971000
&new_flow->key, &acts, log);
@@ -1018,7 +1021,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
10181021
if (ovs_identifier_is_ufid(&new_flow->id))
10191022
flow = ovs_flow_tbl_lookup_ufid(&dp->table, &new_flow->id);
10201023
if (!flow)
1021-
flow = ovs_flow_tbl_lookup(&dp->table, &new_flow->key);
1024+
flow = ovs_flow_tbl_lookup(&dp->table, key);
10221025
if (likely(!flow)) {
10231026
rcu_assign_pointer(new_flow->sf_acts, acts);
10241027

@@ -1088,6 +1091,8 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
10881091

10891092
if (reply)
10901093
ovs_notify(&dp_flow_genl_family, reply, info);
1094+
1095+
kfree(key);
10911096
return 0;
10921097

10931098
err_unlock_ovs:
@@ -1097,6 +1102,8 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
10971102
ovs_nla_free_flow_actions(acts);
10981103
err_kfree_flow:
10991104
ovs_flow_free(new_flow, false);
1105+
err_kfree_key:
1106+
kfree(key);
11001107
error:
11011108
return error;
11021109
}
@@ -1614,7 +1621,8 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb,
16141621
if (IS_ERR(dp))
16151622
return;
16161623

1617-
WARN(dp->user_features, "Dropping previously announced user features\n");
1624+
pr_warn("%s: Dropping previously announced user features\n",
1625+
ovs_dp_name(dp));
16181626
dp->user_features = 0;
16191627
}
16201628

net/openvswitch/flow_netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ static struct sw_flow_actions *nla_alloc_flow_actions(int size)
22802280

22812281
WARN_ON_ONCE(size > MAX_ACTIONS_BUFSIZE);
22822282

2283-
sfa = kmalloc(sizeof(*sfa) + size, GFP_KERNEL);
2283+
sfa = kmalloc(kmalloc_size_roundup(sizeof(*sfa) + size), GFP_KERNEL);
22842284
if (!sfa)
22852285
return ERR_PTR(-ENOMEM);
22862286

0 commit comments

Comments
 (0)