Merge branch '10GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
[platform/kernel/linux-starfive.git] / net / netfilter / nf_nat_core.c
index d8e6380..e29e4cc 100644 (file)
@@ -468,7 +468,7 @@ find_free_id:
        if (range->flags & NF_NAT_RANGE_PROTO_OFFSET)
                off = (ntohs(*keyptr) - ntohs(range->base_proto.all));
        else
-               off = prandom_u32();
+               off = get_random_u16();
 
        attempts = range_size;
        if (attempts > max_attempts)
@@ -490,7 +490,7 @@ another_round:
        if (attempts >= range_size || attempts < 16)
                return;
        attempts /= 2;
-       off = prandom_u32();
+       off = get_random_u16();
        goto another_round;
 }
 
@@ -1152,7 +1152,16 @@ static int __init nf_nat_init(void)
        WARN_ON(nf_nat_hook != NULL);
        RCU_INIT_POINTER(nf_nat_hook, &nat_hook);
 
-       return register_nf_nat_bpf();
+       ret = register_nf_nat_bpf();
+       if (ret < 0) {
+               RCU_INIT_POINTER(nf_nat_hook, NULL);
+               nf_ct_helper_expectfn_unregister(&follow_master_nat);
+               synchronize_net();
+               unregister_pernet_subsys(&nat_net_ops);
+               kvfree(nf_nat_bysource);
+       }
+
+       return ret;
 }
 
 static void __exit nf_nat_cleanup(void)