diff options
Diffstat (limited to 'fs/dlm/config.c')
-rw-r--r-- | fs/dlm/config.c | 79 |
1 files changed, 15 insertions, 64 deletions
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 9ccf7346834a..a0387dd8b1f0 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -750,6 +750,7 @@ static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf, | |||
750 | static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len) | 750 | static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len) |
751 | { | 751 | { |
752 | struct sockaddr_storage *addr; | 752 | struct sockaddr_storage *addr; |
753 | int rv; | ||
753 | 754 | ||
754 | if (len != sizeof(struct sockaddr_storage)) | 755 | if (len != sizeof(struct sockaddr_storage)) |
755 | return -EINVAL; | 756 | return -EINVAL; |
@@ -762,6 +763,13 @@ static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len) | |||
762 | return -ENOMEM; | 763 | return -ENOMEM; |
763 | 764 | ||
764 | memcpy(addr, buf, len); | 765 | memcpy(addr, buf, len); |
766 | |||
767 | rv = dlm_lowcomms_addr(cm->nodeid, addr, len); | ||
768 | if (rv) { | ||
769 | kfree(addr); | ||
770 | return rv; | ||
771 | } | ||
772 | |||
765 | cm->addr[cm->addr_count++] = addr; | 773 | cm->addr[cm->addr_count++] = addr; |
766 | return len; | 774 | return len; |
767 | } | 775 | } |
@@ -878,34 +886,7 @@ static void put_space(struct dlm_space *sp) | |||
878 | config_item_put(&sp->group.cg_item); | 886 | config_item_put(&sp->group.cg_item); |
879 | } | 887 | } |
880 | 888 | ||
881 | static int addr_compare(struct sockaddr_storage *x, struct sockaddr_storage *y) | 889 | static struct dlm_comm *get_comm(int nodeid) |
882 | { | ||
883 | switch (x->ss_family) { | ||
884 | case AF_INET: { | ||
885 | struct sockaddr_in *sinx = (struct sockaddr_in *)x; | ||
886 | struct sockaddr_in *siny = (struct sockaddr_in *)y; | ||
887 | if (sinx->sin_addr.s_addr != siny->sin_addr.s_addr) | ||
888 | return 0; | ||
889 | if (sinx->sin_port != siny->sin_port) | ||
890 | return 0; | ||
891 | break; | ||
892 | } | ||
893 | case AF_INET6: { | ||
894 | struct sockaddr_in6 *sinx = (struct sockaddr_in6 *)x; | ||
895 | struct sockaddr_in6 *siny = (struct sockaddr_in6 *)y; | ||
896 | if (!ipv6_addr_equal(&sinx->sin6_addr, &siny->sin6_addr)) | ||
897 | return 0; | ||
898 | if (sinx->sin6_port != siny->sin6_port) | ||
899 | return 0; | ||
900 | break; | ||
901 | } | ||
902 | default: | ||
903 | return 0; | ||
904 | } | ||
905 | return 1; | ||
906 | } | ||
907 | |||
908 | static struct dlm_comm *get_comm(int nodeid, struct sockaddr_storage *addr) | ||
909 | { | 890 | { |
910 | struct config_item *i; | 891 | struct config_item *i; |
911 | struct dlm_comm *cm = NULL; | 892 | struct dlm_comm *cm = NULL; |
@@ -919,19 +900,11 @@ static struct dlm_comm *get_comm(int nodeid, struct sockaddr_storage *addr) | |||
919 | list_for_each_entry(i, &comm_list->cg_children, ci_entry) { | 900 | list_for_each_entry(i, &comm_list->cg_children, ci_entry) { |
920 | cm = config_item_to_comm(i); | 901 | cm = config_item_to_comm(i); |
921 | 902 | ||
922 | if (nodeid) { | 903 | if (cm->nodeid != nodeid) |
923 | if (cm->nodeid != nodeid) | 904 | continue; |
924 | continue; | 905 | found = 1; |
925 | found = 1; | 906 | config_item_get(i); |
926 | config_item_get(i); | 907 | break; |
927 | break; | ||
928 | } else { | ||
929 | if (!cm->addr_count || !addr_compare(cm->addr[0], addr)) | ||
930 | continue; | ||
931 | found = 1; | ||
932 | config_item_get(i); | ||
933 | break; | ||
934 | } | ||
935 | } | 908 | } |
936 | mutex_unlock(&clusters_root.subsys.su_mutex); | 909 | mutex_unlock(&clusters_root.subsys.su_mutex); |
937 | 910 | ||
@@ -995,7 +968,7 @@ int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out, | |||
995 | 968 | ||
996 | int dlm_comm_seq(int nodeid, uint32_t *seq) | 969 | int dlm_comm_seq(int nodeid, uint32_t *seq) |
997 | { | 970 | { |
998 | struct dlm_comm *cm = get_comm(nodeid, NULL); | 971 | struct dlm_comm *cm = get_comm(nodeid); |
999 | if (!cm) | 972 | if (!cm) |
1000 | return -EEXIST; | 973 | return -EEXIST; |
1001 | *seq = cm->seq; | 974 | *seq = cm->seq; |
@@ -1003,28 +976,6 @@ int dlm_comm_seq(int nodeid, uint32_t *seq) | |||
1003 | return 0; | 976 | return 0; |
1004 | } | 977 | } |
1005 | 978 | ||
1006 | int dlm_nodeid_to_addr(int nodeid, struct sockaddr_storage *addr) | ||
1007 | { | ||
1008 | struct dlm_comm *cm = get_comm(nodeid, NULL); | ||
1009 | if (!cm) | ||
1010 | return -EEXIST; | ||
1011 | if (!cm->addr_count) | ||
1012 | return -ENOENT; | ||
1013 | memcpy(addr, cm->addr[0], sizeof(*addr)); | ||
1014 | put_comm(cm); | ||
1015 | return 0; | ||
1016 | } | ||
1017 | |||
1018 | int dlm_addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid) | ||
1019 | { | ||
1020 | struct dlm_comm *cm = get_comm(0, addr); | ||
1021 | if (!cm) | ||
1022 | return -EEXIST; | ||
1023 | *nodeid = cm->nodeid; | ||
1024 | put_comm(cm); | ||
1025 | return 0; | ||
1026 | } | ||
1027 | |||
1028 | int dlm_our_nodeid(void) | 979 | int dlm_our_nodeid(void) |
1029 | { | 980 | { |
1030 | return local_comm ? local_comm->nodeid : 0; | 981 | return local_comm ? local_comm->nodeid : 0; |