Skip to content

Commit f16afb5

Browse files
authored
Merge pull request #22 from chu11/pingd_receive_buffer
pingd: support ping_socket_receive_buffer
2 parents 1cd4141 + 4a014b5 commit f16afb5

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

man/pingd.conf.5.in

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ regularly sent out. Default is 15000.
5353
Specify the alternate default port the pingd server should listen
5454
for requests off of. Default is 9125.
5555
.TP
56+
.I ping_socket_receive_buffer bytecount
57+
Specify size of the socket receive buffer in bytes. This may be
58+
necessary on larger clusters where the default buffer cannot hold
59+
all ping responses. System default used if set to <= 0.
60+
.TP
5661
.I host string
5762
Specify a host the pingd daemon should regularly ping. Can be
5863
specified as many times as necessary.

src/pingd/pingd_config.c

+15
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ _config_default(void)
7676
conf.config_file = PINGD_CONF_FILE;
7777
conf.ping_period = PINGD_PING_PERIOD_DEFAULT;
7878
conf.pingd_server_port = PINGD_SERVER_PORT_DEFAULT;
79+
conf.ping_socket_receive_buffer = PINGD_PING_SOCKET_RECEIVE_BUFFER;
7980

8081
if (!(conf.hosts = hostlist_create(NULL)))
8182
ERR_EXIT(("hostlist_create: %s", strerror(errno)));
@@ -189,6 +190,7 @@ _config_file_parse(void)
189190
{
190191
int ping_period_flag,
191192
pingd_server_port_flag,
193+
ping_socket_receive_buffer_flag,
192194
host_flag;
193195

194196
struct conffile_option options[] =
@@ -215,6 +217,17 @@ _config_file_parse(void)
215217
&(conf.pingd_server_port),
216218
0,
217219
},
220+
{
221+
"ping_socket_receive_buffer",
222+
CONFFILE_OPTION_INT,
223+
-1,
224+
conffile_int,
225+
1,
226+
0,
227+
&(ping_socket_receive_buffer_flag),
228+
&(conf.ping_socket_receive_buffer),
229+
0
230+
},
218231
{
219232
"host",
220233
CONFFILE_OPTION_STRING,
@@ -486,6 +499,8 @@ pingd_config_setup(int argc, char **argv)
486499
fprintf(stderr, "conf.debug = %d\n", conf.debug);
487500
fprintf(stderr, "conf.ping_period = %d\n", conf.ping_period);
488501
fprintf(stderr, "conf.pingd_server_port = %d\n", conf.pingd_server_port);
502+
fprintf(stderr, "conf.ping_socket_receive_buffer = %d\n",
503+
conf.ping_socket_receive_buffer);
489504
hostlist_ranged_string(conf.hosts, 1024, hbuf);
490505
fprintf(stderr, "conf.hosts = %s\n", hbuf);
491506
}

src/pingd/pingd_config.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333

3434
#include "hostlist.h"
3535

36-
#define PINGD_DEBUG_DEFAULT 0
37-
#define PINGD_PING_PERIOD_DEFAULT 15000
38-
#define PINGD_SERVER_PORT_DEFAULT 9125
36+
#define PINGD_DEBUG_DEFAULT 0
37+
#define PINGD_PING_PERIOD_DEFAULT 15000
38+
#define PINGD_SERVER_PORT_DEFAULT 9125
39+
#define PINGD_PING_SOCKET_RECEIVE_BUFFER 0
3940

4041
struct pingd_config
4142
{
@@ -46,6 +47,7 @@ struct pingd_config
4647

4748
int ping_period;
4849
int pingd_server_port;
50+
int ping_socket_receive_buffer;
4951
hostlist_t hosts;
5052
};
5153

src/pingd/pingd_loop.c

+10
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ _fds_setup(void)
109109
if ((ping_fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
110110
ERR_EXIT(("socket: %s", strerror(errno)));
111111

112+
if (conf.ping_socket_receive_buffer > 0)
113+
{
114+
if (setsockopt(ping_fd,
115+
SOL_SOCKET,
116+
SO_RCVBUF,
117+
&conf.ping_socket_receive_buffer,
118+
sizeof(conf.ping_socket_receive_buffer)) < 0)
119+
ERR_EXIT(("setsockopt: %s", strerror(errno)));
120+
}
121+
112122
memset(&addr, '\0', sizeof(struct sockaddr_in));
113123
addr.sin_family = AF_INET;
114124
addr.sin_port = htons(0);

0 commit comments

Comments
 (0)