Commit 87c3efbf authored by Daniel Lezcano's avatar Daniel Lezcano Committed by David S. Miller

[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: default avatarDaniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 853cbbaa
...@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(struct inet_protosw *p); ...@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(struct inet_protosw *p);
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num);
extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num);
extern void inet6_register_protosw(struct inet_protosw *p); extern int inet6_register_protosw(struct inet_protosw *p);
extern void inet6_unregister_protosw(struct inet_protosw *p); extern void inet6_unregister_protosw(struct inet_protosw *p);
#endif #endif
......
...@@ -565,21 +565,23 @@ static struct inet_protosw rawv6_protosw = { ...@@ -565,21 +565,23 @@ static struct inet_protosw rawv6_protosw = {
.flags = INET_PROTOSW_REUSE, .flags = INET_PROTOSW_REUSE,
}; };
void int inet6_register_protosw(struct inet_protosw *p)
inet6_register_protosw(struct inet_protosw *p)
{ {
struct list_head *lh; struct list_head *lh;
struct inet_protosw *answer; struct inet_protosw *answer;
int protocol = p->protocol;
struct list_head *last_perm; struct list_head *last_perm;
int protocol = p->protocol;
int ret;
spin_lock_bh(&inetsw6_lock); spin_lock_bh(&inetsw6_lock);
ret = -EINVAL;
if (p->type >= SOCK_MAX) if (p->type >= SOCK_MAX)
goto out_illegal; goto out_illegal;
/* If we are trying to override a permanent protocol, bail. */ /* If we are trying to override a permanent protocol, bail. */
answer = NULL; answer = NULL;
ret = -EPERM;
last_perm = &inetsw6[p->type]; last_perm = &inetsw6[p->type];
list_for_each(lh, &inetsw6[p->type]) { list_for_each(lh, &inetsw6[p->type]) {
answer = list_entry(lh, struct inet_protosw, list); answer = list_entry(lh, struct inet_protosw, list);
...@@ -603,9 +605,10 @@ inet6_register_protosw(struct inet_protosw *p) ...@@ -603,9 +605,10 @@ inet6_register_protosw(struct inet_protosw *p)
* system automatically returns to the old behavior. * system automatically returns to the old behavior.
*/ */
list_add_rcu(&p->list, last_perm); list_add_rcu(&p->list, last_perm);
ret = 0;
out: out:
spin_unlock_bh(&inetsw6_lock); spin_unlock_bh(&inetsw6_lock);
return; return ret;
out_permanent: out_permanent:
printk(KERN_ERR "Attempt to override permanent protocol %d.\n", printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment