diff options
Diffstat (limited to 'net/tipc/port.c')
| -rw-r--r-- | net/tipc/port.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c index c081a7632302..b742b2654525 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
| @@ -251,18 +251,15 @@ struct tipc_port *tipc_createport(struct sock *sk, | |||
| 251 | return p_ptr; | 251 | return p_ptr; |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | int tipc_deleteport(u32 ref) | 254 | int tipc_deleteport(struct tipc_port *p_ptr) |
| 255 | { | 255 | { |
| 256 | struct tipc_port *p_ptr; | ||
| 257 | struct sk_buff *buf = NULL; | 256 | struct sk_buff *buf = NULL; |
| 258 | 257 | ||
| 259 | tipc_withdraw(ref, 0, NULL); | 258 | tipc_withdraw(p_ptr, 0, NULL); |
| 260 | p_ptr = tipc_port_lock(ref); | ||
| 261 | if (!p_ptr) | ||
| 262 | return -EINVAL; | ||
| 263 | 259 | ||
| 264 | tipc_ref_discard(ref); | 260 | spin_lock_bh(p_ptr->lock); |
| 265 | tipc_port_unlock(p_ptr); | 261 | tipc_ref_discard(p_ptr->ref); |
| 262 | spin_unlock_bh(p_ptr->lock); | ||
| 266 | 263 | ||
| 267 | k_cancel_timer(&p_ptr->timer); | 264 | k_cancel_timer(&p_ptr->timer); |
| 268 | if (p_ptr->connected) { | 265 | if (p_ptr->connected) { |
| @@ -704,47 +701,36 @@ int tipc_set_portimportance(u32 ref, unsigned int imp) | |||
| 704 | } | 701 | } |
| 705 | 702 | ||
| 706 | 703 | ||
| 707 | int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | 704 | int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, |
| 705 | struct tipc_name_seq const *seq) | ||
| 708 | { | 706 | { |
| 709 | struct tipc_port *p_ptr; | ||
| 710 | struct publication *publ; | 707 | struct publication *publ; |
| 711 | u32 key; | 708 | u32 key; |
| 712 | int res = -EINVAL; | ||
| 713 | 709 | ||
| 714 | p_ptr = tipc_port_lock(ref); | 710 | if (p_ptr->connected) |
| 715 | if (!p_ptr) | ||
| 716 | return -EINVAL; | 711 | return -EINVAL; |
| 712 | key = p_ptr->ref + p_ptr->pub_count + 1; | ||
| 713 | if (key == p_ptr->ref) | ||
| 714 | return -EADDRINUSE; | ||
| 717 | 715 | ||
| 718 | if (p_ptr->connected) | ||
| 719 | goto exit; | ||
| 720 | key = ref + p_ptr->pub_count + 1; | ||
| 721 | if (key == ref) { | ||
| 722 | res = -EADDRINUSE; | ||
| 723 | goto exit; | ||
| 724 | } | ||
| 725 | publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, | 716 | publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, |
| 726 | scope, p_ptr->ref, key); | 717 | scope, p_ptr->ref, key); |
| 727 | if (publ) { | 718 | if (publ) { |
| 728 | list_add(&publ->pport_list, &p_ptr->publications); | 719 | list_add(&publ->pport_list, &p_ptr->publications); |
| 729 | p_ptr->pub_count++; | 720 | p_ptr->pub_count++; |
| 730 | p_ptr->published = 1; | 721 | p_ptr->published = 1; |
| 731 | res = 0; | 722 | return 0; |
| 732 | } | 723 | } |
| 733 | exit: | 724 | return -EINVAL; |
| 734 | tipc_port_unlock(p_ptr); | ||
| 735 | return res; | ||
| 736 | } | 725 | } |
| 737 | 726 | ||
| 738 | int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | 727 | int tipc_withdraw(struct tipc_port *p_ptr, unsigned int scope, |
| 728 | struct tipc_name_seq const *seq) | ||
| 739 | { | 729 | { |
| 740 | struct tipc_port *p_ptr; | ||
| 741 | struct publication *publ; | 730 | struct publication *publ; |
| 742 | struct publication *tpubl; | 731 | struct publication *tpubl; |
| 743 | int res = -EINVAL; | 732 | int res = -EINVAL; |
| 744 | 733 | ||
| 745 | p_ptr = tipc_port_lock(ref); | ||
| 746 | if (!p_ptr) | ||
| 747 | return -EINVAL; | ||
| 748 | if (!seq) { | 734 | if (!seq) { |
| 749 | list_for_each_entry_safe(publ, tpubl, | 735 | list_for_each_entry_safe(publ, tpubl, |
| 750 | &p_ptr->publications, pport_list) { | 736 | &p_ptr->publications, pport_list) { |
| @@ -771,7 +757,6 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) | |||
| 771 | } | 757 | } |
| 772 | if (list_empty(&p_ptr->publications)) | 758 | if (list_empty(&p_ptr->publications)) |
| 773 | p_ptr->published = 0; | 759 | p_ptr->published = 0; |
| 774 | tipc_port_unlock(p_ptr); | ||
| 775 | return res; | 760 | return res; |
| 776 | } | 761 | } |
| 777 | 762 | ||
| @@ -832,17 +817,14 @@ exit: | |||
| 832 | */ | 817 | */ |
| 833 | int __tipc_disconnect(struct tipc_port *tp_ptr) | 818 | int __tipc_disconnect(struct tipc_port *tp_ptr) |
| 834 | { | 819 | { |
| 835 | int res; | ||
| 836 | |||
| 837 | if (tp_ptr->connected) { | 820 | if (tp_ptr->connected) { |
| 838 | tp_ptr->connected = 0; | 821 | tp_ptr->connected = 0; |
| 839 | /* let timer expire on it's own to avoid deadlock! */ | 822 | /* let timer expire on it's own to avoid deadlock! */ |
| 840 | tipc_nodesub_unsubscribe(&tp_ptr->subscription); | 823 | tipc_nodesub_unsubscribe(&tp_ptr->subscription); |
| 841 | res = 0; | 824 | return 0; |
| 842 | } else { | ||
| 843 | res = -ENOTCONN; | ||
| 844 | } | 825 | } |
| 845 | return res; | 826 | |
| 827 | return -ENOTCONN; | ||
| 846 | } | 828 | } |
| 847 | 829 | ||
| 848 | /* | 830 | /* |
