Skip to content

Commit 853cbba

Browse files
Daniel Lezcanodavem330
authored andcommitted
[IPV6]: make frag to return an error at initialization
This patch makes the frag_init to return an error code, so the af_inet6 module can handle the error. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 248b238 commit 853cbba

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎include/net/transp_v6.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ struct flowi;
1919
/* extention headers */
2020
extern int ipv6_exthdrs_init(void);
2121
extern void ipv6_exthdrs_exit(void);
22-
extern void ipv6_frag_init(void);
22+
extern int ipv6_frag_init(void);
23+
extern void ipv6_frag_exit(void);
2324

2425
/* transport protocols */
2526
extern void rawv6_init(void);

‎net/ipv6/af_inet6.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,9 @@ static int __init inet6_init(void)
863863
if (err)
864864
goto ipv6_exthdrs_fail;
865865

866-
ipv6_frag_init();
866+
err = ipv6_frag_init();
867+
if (err)
868+
goto ipv6_frag_fail;
867869

868870
/* Init v6 transport protocols. */
869871
udpv6_init();
@@ -875,6 +877,8 @@ static int __init inet6_init(void)
875877
out:
876878
return err;
877879

880+
ipv6_frag_fail:
881+
ipv6_exthdrs_exit();
878882
ipv6_exthdrs_fail:
879883
addrconf_cleanup();
880884
addrconf_fail:
@@ -934,7 +938,7 @@ static void __exit inet6_exit(void)
934938

935939
/* Cleanup code parts. */
936940
ipv6_packet_cleanup();
937-
941+
ipv6_frag_exit();
938942
ipv6_exthdrs_exit();
939943
addrconf_cleanup();
940944
ip6_flowlabel_cleanup();

‎net/ipv6/reassembly.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,13 @@ static struct inet6_protocol frag_protocol =
632632
.flags = INET6_PROTO_NOPOLICY,
633633
};
634634

635-
void __init ipv6_frag_init(void)
635+
int __init ipv6_frag_init(void)
636636
{
637-
if (inet6_add_protocol(&frag_protocol, IPPROTO_FRAGMENT) < 0)
638-
printk(KERN_ERR "ipv6_frag_init: Could not register protocol\n");
637+
int ret;
639638

639+
ret = inet6_add_protocol(&frag_protocol, IPPROTO_FRAGMENT);
640+
if (ret)
641+
goto out;
640642
ip6_frags.ctl = &ip6_frags_ctl;
641643
ip6_frags.hashfn = ip6_hashfn;
642644
ip6_frags.constructor = ip6_frag_init;
@@ -646,4 +648,12 @@ void __init ipv6_frag_init(void)
646648
ip6_frags.match = ip6_frag_match;
647649
ip6_frags.frag_expire = ip6_frag_expire;
648650
inet_frags_init(&ip6_frags);
651+
out:
652+
return ret;
653+
}
654+
655+
void ipv6_frag_exit(void)
656+
{
657+
inet_frags_fini(&ip6_frags);
658+
inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
649659
}

0 commit comments

Comments
 (0)