Dmitry V. Krivenok
2009-05-04 07:22:47 UTC
Hello!
I wrote simple SNMP-client to test polling performance.
As you know SNMP works over UDP and my question
is about UDP socket and sendto system call.
My program is designed to poll devices "asynchronously", i.e.
at first I create N non-blocking sockets, then I send all requests
using sendto() and then wait for responses using select (in this
version, but I'm going to use epool in Linux).
The program works fine when I poll few hundred of devices,
but I get strange error when I poll several thousand of devices:
sendto returns -1 with errno set to EPERM (Operation not permitted).
sendto (2) manual page doesn't say anything about EPERM
error.
I searched through the google and found, that sendto may
fail with errno == EPERM if local firewall disallows outgoing UDP
packets.
iptables v1.2.11 is installed on target host, however OUTPUT
chain is empty:
#iptables -L OUTPUT -v -n
Chain OUTPUT (policy ACCEPT 39G packets, 7676G bytes)
pkts bytes target prot opt in out source
destination
#
I traced my program using strace utility and all
system calls related to the socket 22 are shown below:
5169 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 22
...
...
5169 fcntl64(22, F_GETFL) = 0x2 (flags O_RDWR)
5169 fcntl64(22, F_SETFL, O_RDWR|O_NONBLOCK) = 0
...
5169 sendto(22, "0&\2\1\1\4\6public
\240\31\2\1\23\2\1\0\2\1\0000\0160\f"..., 40, 0, {sa_family=AF_INET,
sin_port=htons(161), sin_addr=inet_addr("10.19.120.1
")}, 16) = 40
5169 sendto(22, "0&\2\1\1\4\6public\240\31\2\1w\2\1\0\2\1\0000\0160\f
\6"..., 40, 0, {sa_family=AF_INET, sin_port=htons(161),
sin_addr=inet_addr("10.219.130.
46")}, 16) = 40
5169 sendto(22, "0\'\2\1\1\4\6public
\240\32\2\2\0\333\2\1\0\2\1\0000\016"..., 41, 0, {sa_family=AF_INET,
sin_port=htons(161), sin_addr=inet_addr("10.219.146
.78")}, 16) = 41
...
...
...
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1^
\333\2\1\0\2\1\0000\016"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.6.185.1
91")}, 16) = 42
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1_?
\2\1\0\2\1\0000\0160\f"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.7.2.199
")}, 16) = 42
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1_
\243\2\1\0\2\1\0000\016"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.8.51.52
")}, 16) = 42
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1`
\7\2\1\0\2\1\0000\0160"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.9.73.167
")}, 16) = -1 EPERM (Operation not permitted)
What may be the cause of my problem?
Any ideas?
Thank you beforehand!
I wrote simple SNMP-client to test polling performance.
As you know SNMP works over UDP and my question
is about UDP socket and sendto system call.
My program is designed to poll devices "asynchronously", i.e.
at first I create N non-blocking sockets, then I send all requests
using sendto() and then wait for responses using select (in this
version, but I'm going to use epool in Linux).
The program works fine when I poll few hundred of devices,
but I get strange error when I poll several thousand of devices:
sendto returns -1 with errno set to EPERM (Operation not permitted).
sendto (2) manual page doesn't say anything about EPERM
error.
I searched through the google and found, that sendto may
fail with errno == EPERM if local firewall disallows outgoing UDP
packets.
iptables v1.2.11 is installed on target host, however OUTPUT
chain is empty:
#iptables -L OUTPUT -v -n
Chain OUTPUT (policy ACCEPT 39G packets, 7676G bytes)
pkts bytes target prot opt in out source
destination
#
I traced my program using strace utility and all
system calls related to the socket 22 are shown below:
5169 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 22
...
...
5169 fcntl64(22, F_GETFL) = 0x2 (flags O_RDWR)
5169 fcntl64(22, F_SETFL, O_RDWR|O_NONBLOCK) = 0
...
5169 sendto(22, "0&\2\1\1\4\6public
\240\31\2\1\23\2\1\0\2\1\0000\0160\f"..., 40, 0, {sa_family=AF_INET,
sin_port=htons(161), sin_addr=inet_addr("10.19.120.1
")}, 16) = 40
5169 sendto(22, "0&\2\1\1\4\6public\240\31\2\1w\2\1\0\2\1\0000\0160\f
\6"..., 40, 0, {sa_family=AF_INET, sin_port=htons(161),
sin_addr=inet_addr("10.219.130.
46")}, 16) = 40
5169 sendto(22, "0\'\2\1\1\4\6public
\240\32\2\2\0\333\2\1\0\2\1\0000\016"..., 41, 0, {sa_family=AF_INET,
sin_port=htons(161), sin_addr=inet_addr("10.219.146
.78")}, 16) = 41
...
...
...
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1^
\333\2\1\0\2\1\0000\016"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.6.185.1
91")}, 16) = 42
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1_?
\2\1\0\2\1\0000\0160\f"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.7.2.199
")}, 16) = 42
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1_
\243\2\1\0\2\1\0000\016"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.8.51.52
")}, 16) = 42
5169 sendto(22, "0(\2\1\1\4\6public\240\33\2\3\1`
\7\2\1\0\2\1\0000\0160"..., 42, 0, {sa_family=AF_INET, sin_port=htons
(161), sin_addr=inet_addr("10.9.73.167
")}, 16) = -1 EPERM (Operation not permitted)
What may be the cause of my problem?
Any ideas?
Thank you beforehand!