@@ -165,7 +165,7 @@ static LIST_HEAD(dlm_node_addrs);
165
165
static DEFINE_SPINLOCK (dlm_node_addrs_spin );
166
166
167
167
static struct listen_connection listen_con ;
168
- static struct sockaddr_storage * dlm_local_addr [DLM_MAX_ADDR_COUNT ];
168
+ static struct sockaddr_storage dlm_local_addr [DLM_MAX_ADDR_COUNT ];
169
169
static int dlm_local_count ;
170
170
171
171
/* Work queues */
@@ -383,7 +383,7 @@ static int nodeid_to_addr(int nodeid, struct sockaddr_storage *sas_out,
383
383
if (!sa_out )
384
384
return 0 ;
385
385
386
- if (dlm_local_addr [0 ]-> ss_family == AF_INET ) {
386
+ if (dlm_local_addr [0 ]. ss_family == AF_INET ) {
387
387
struct sockaddr_in * in4 = (struct sockaddr_in * ) & sas ;
388
388
struct sockaddr_in * ret4 = (struct sockaddr_in * ) sa_out ;
389
389
ret4 -> sin_addr .s_addr = in4 -> sin_addr .s_addr ;
@@ -683,7 +683,7 @@ static void add_sock(struct socket *sock, struct connection *con)
683
683
static void make_sockaddr (struct sockaddr_storage * saddr , uint16_t port ,
684
684
int * addr_len )
685
685
{
686
- saddr -> ss_family = dlm_local_addr [0 ]-> ss_family ;
686
+ saddr -> ss_family = dlm_local_addr [0 ]. ss_family ;
687
687
if (saddr -> ss_family == AF_INET ) {
688
688
struct sockaddr_in * in4_addr = (struct sockaddr_in * )saddr ;
689
689
in4_addr -> sin_port = cpu_to_be16 (port );
@@ -1065,7 +1065,7 @@ static int sctp_bind_addrs(struct socket *sock, uint16_t port)
1065
1065
int i , addr_len , result = 0 ;
1066
1066
1067
1067
for (i = 0 ; i < dlm_local_count ; i ++ ) {
1068
- memcpy (& localaddr , dlm_local_addr [i ], sizeof (localaddr ));
1068
+ memcpy (& localaddr , & dlm_local_addr [i ], sizeof (localaddr ));
1069
1069
make_sockaddr (& localaddr , port , & addr_len );
1070
1070
1071
1071
if (!i )
@@ -1085,29 +1085,18 @@ static int sctp_bind_addrs(struct socket *sock, uint16_t port)
1085
1085
/* Get local addresses */
1086
1086
static void init_local (void )
1087
1087
{
1088
- struct sockaddr_storage sas , * addr ;
1088
+ struct sockaddr_storage sas ;
1089
1089
int i ;
1090
1090
1091
1091
dlm_local_count = 0 ;
1092
1092
for (i = 0 ; i < DLM_MAX_ADDR_COUNT ; i ++ ) {
1093
1093
if (dlm_our_addr (& sas , i ))
1094
1094
break ;
1095
1095
1096
- addr = kmemdup (& sas , sizeof (* addr ), GFP_NOFS );
1097
- if (!addr )
1098
- break ;
1099
- dlm_local_addr [dlm_local_count ++ ] = addr ;
1096
+ memcpy (& dlm_local_addr [dlm_local_count ++ ], & sas , sizeof (sas ));
1100
1097
}
1101
1098
}
1102
1099
1103
- static void deinit_local (void )
1104
- {
1105
- int i ;
1106
-
1107
- for (i = 0 ; i < dlm_local_count ; i ++ )
1108
- kfree (dlm_local_addr [i ]);
1109
- }
1110
-
1111
1100
static struct writequeue_entry * new_writequeue_entry (struct connection * con )
1112
1101
{
1113
1102
struct writequeue_entry * entry ;
@@ -1463,7 +1452,7 @@ static void dlm_connect(struct connection *con)
1463
1452
}
1464
1453
1465
1454
/* Create a socket to communicate with */
1466
- result = sock_create_kern (& init_net , dlm_local_addr [0 ]-> ss_family ,
1455
+ result = sock_create_kern (& init_net , dlm_local_addr [0 ]. ss_family ,
1467
1456
SOCK_STREAM , dlm_proto_ops -> proto , & sock );
1468
1457
if (result < 0 )
1469
1458
goto socket_err ;
@@ -1679,7 +1668,6 @@ void dlm_lowcomms_stop(void)
1679
1668
foreach_conn (free_conn );
1680
1669
srcu_read_unlock (& connections_srcu , idx );
1681
1670
work_stop ();
1682
- deinit_local ();
1683
1671
1684
1672
dlm_proto_ops = NULL ;
1685
1673
}
@@ -1696,7 +1684,7 @@ static int dlm_listen_for_all(void)
1696
1684
if (result < 0 )
1697
1685
return result ;
1698
1686
1699
- result = sock_create_kern (& init_net , dlm_local_addr [0 ]-> ss_family ,
1687
+ result = sock_create_kern (& init_net , dlm_local_addr [0 ]. ss_family ,
1700
1688
SOCK_STREAM , dlm_proto_ops -> proto , & sock );
1701
1689
if (result < 0 ) {
1702
1690
log_print ("Can't create comms socket: %d" , result );
@@ -1743,7 +1731,7 @@ static int dlm_tcp_bind(struct socket *sock)
1743
1731
/* Bind to our cluster-known address connecting to avoid
1744
1732
* routing problems.
1745
1733
*/
1746
- memcpy (& src_addr , dlm_local_addr [0 ], sizeof (src_addr ));
1734
+ memcpy (& src_addr , & dlm_local_addr [0 ], sizeof (src_addr ));
1747
1735
make_sockaddr (& src_addr , 0 , & addr_len );
1748
1736
1749
1737
result = sock -> ops -> bind (sock , (struct sockaddr * )& src_addr ,
@@ -1800,8 +1788,8 @@ static int dlm_tcp_listen_bind(struct socket *sock)
1800
1788
int addr_len ;
1801
1789
1802
1790
/* Bind to our port */
1803
- make_sockaddr (dlm_local_addr [0 ], dlm_config .ci_tcp_port , & addr_len );
1804
- return sock -> ops -> bind (sock , (struct sockaddr * )dlm_local_addr [0 ],
1791
+ make_sockaddr (& dlm_local_addr [0 ], dlm_config .ci_tcp_port , & addr_len );
1792
+ return sock -> ops -> bind (sock , (struct sockaddr * )& dlm_local_addr [0 ],
1805
1793
addr_len );
1806
1794
}
1807
1795
@@ -1891,7 +1879,7 @@ int dlm_lowcomms_start(void)
1891
1879
1892
1880
error = work_start ();
1893
1881
if (error )
1894
- goto fail_local ;
1882
+ goto fail ;
1895
1883
1896
1884
/* Start listening */
1897
1885
switch (dlm_config .ci_protocol ) {
@@ -1918,8 +1906,6 @@ int dlm_lowcomms_start(void)
1918
1906
dlm_proto_ops = NULL ;
1919
1907
fail_proto_ops :
1920
1908
work_stop ();
1921
- fail_local :
1922
- deinit_local ();
1923
1909
fail :
1924
1910
return error ;
1925
1911
}
0 commit comments