aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/protocol.h2
-rw-r--r--net/ipv6/af_inet6.c11
2 files changed, 8 insertions, 5 deletions
diff --git a/include/net/protocol.h b/include/net/protocol.h
index 1166ffb4b3ec..ad8c584233a6 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(struct inet_protosw *p);
102#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 102#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
103extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); 103extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num);
104extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); 104extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num);
105extern void inet6_register_protosw(struct inet_protosw *p); 105extern int inet6_register_protosw(struct inet_protosw *p);
106extern void inet6_unregister_protosw(struct inet_protosw *p); 106extern void inet6_unregister_protosw(struct inet_protosw *p);
107#endif 107#endif
108 108
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index a75c4bc9281a..53b06de696bd 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -565,21 +565,23 @@ static struct inet_protosw rawv6_protosw = {
565 .flags = INET_PROTOSW_REUSE, 565 .flags = INET_PROTOSW_REUSE,
566}; 566};
567 567
568void 568int inet6_register_protosw(struct inet_protosw *p)
569inet6_register_protosw(struct inet_protosw *p)
570{ 569{
571 struct list_head *lh; 570 struct list_head *lh;
572 struct inet_protosw *answer; 571 struct inet_protosw *answer;
573 int protocol = p->protocol;
574 struct list_head *last_perm; 572 struct list_head *last_perm;
573 int protocol = p->protocol;
574 int ret;
575 575
576 spin_lock_bh(&inetsw6_lock); 576 spin_lock_bh(&inetsw6_lock);
577 577
578 ret = -EINVAL;
578 if (p->type >= SOCK_MAX) 579 if (p->type >= SOCK_MAX)
579 goto out_illegal; 580 goto out_illegal;
580 581
581 /* If we are trying to override a permanent protocol, bail. */ 582 /* If we are trying to override a permanent protocol, bail. */
582 answer = NULL; 583 answer = NULL;
584 ret = -EPERM;
583 last_perm = &inetsw6[p->type]; 585 last_perm = &inetsw6[p->type];
584 list_for_each(lh, &inetsw6[p->type]) { 586 list_for_each(lh, &inetsw6[p->type]) {
585 answer = list_entry(lh, struct inet_protosw, list); 587 answer = list_entry(lh, struct inet_protosw, list);
@@ -603,9 +605,10 @@ inet6_register_protosw(struct inet_protosw *p)
603 * system automatically returns to the old behavior. 605 * system automatically returns to the old behavior.
604 */ 606 */
605 list_add_rcu(&p->list, last_perm); 607 list_add_rcu(&p->list, last_perm);
608 ret = 0;
606out: 609out:
607 spin_unlock_bh(&inetsw6_lock); 610 spin_unlock_bh(&inetsw6_lock);
608 return; 611 return ret;
609 612
610out_permanent: 613out_permanent:
611 printk(KERN_ERR "Attempt to override permanent protocol %d.\n", 614 printk(KERN_ERR "Attempt to override permanent protocol %d.\n",