Skip to content

Commit 87c3efb

Browse files
Daniel Lezcanodavem330
authored andcommitted
[IPV6]: make inet6_register_protosw to return an error code
This patch makes the inet6_register_protosw to return an error code. The different protocols can be aware the registration was successful or not and can pass the error to the initial caller, af_inet6. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 853cbba commit 87c3efb

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎include/net/protocol.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(struct inet_protosw *p);
102102
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
103103
extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num);
104104
extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num);
105-
extern void inet6_register_protosw(struct inet_protosw *p);
105+
extern int inet6_register_protosw(struct inet_protosw *p);
106106
extern void inet6_unregister_protosw(struct inet_protosw *p);
107107
#endif
108108

‎net/ipv6/af_inet6.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,21 +565,23 @@ static struct inet_protosw rawv6_protosw = {
565565
.flags = INET_PROTOSW_REUSE,
566566
};
567567

568-
void
569-
inet6_register_protosw(struct inet_protosw *p)
568+
int inet6_register_protosw(struct inet_protosw *p)
570569
{
571570
struct list_head *lh;
572571
struct inet_protosw *answer;
573-
int protocol = p->protocol;
574572
struct list_head *last_perm;
573+
int protocol = p->protocol;
574+
int ret;
575575

576576
spin_lock_bh(&inetsw6_lock);
577577

578+
ret = -EINVAL;
578579
if (p->type >= SOCK_MAX)
579580
goto out_illegal;
580581

581582
/* If we are trying to override a permanent protocol, bail. */
582583
answer = NULL;
584+
ret = -EPERM;
583585
last_perm = &inetsw6[p->type];
584586
list_for_each(lh, &inetsw6[p->type]) {
585587
answer = list_entry(lh, struct inet_protosw, list);
@@ -603,9 +605,10 @@ inet6_register_protosw(struct inet_protosw *p)
603605
* system automatically returns to the old behavior.
604606
*/
605607
list_add_rcu(&p->list, last_perm);
608+
ret = 0;
606609
out:
607610
spin_unlock_bh(&inetsw6_lock);
608-
return;
611+
return ret;
609612

610613
out_permanent:
611614
printk(KERN_ERR "Attempt to override permanent protocol %d.\n",

0 commit comments

Comments
 (0)