util: Don't close ping sockets if bind() fails
...they're still usable, thanks to the workaround implemented in icmp_tap_handler(). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
a340e5336d
commit
ce24fe0b3f
1 changed files with 6 additions and 3 deletions
9
util.c
9
util.c
|
@ -189,10 +189,13 @@ int sock_l4(struct ctx *c, int af, uint8_t proto, uint16_t port,
|
||||||
if (bind(fd, sa, sl) < 0) {
|
if (bind(fd, sa, sl) < 0) {
|
||||||
/* We'll fail to bind to low ports if we don't have enough
|
/* We'll fail to bind to low ports if we don't have enough
|
||||||
* capabilities, and we'll fail to bind on already bound ports,
|
* capabilities, and we'll fail to bind on already bound ports,
|
||||||
* this is fine.
|
* this is fine. This might also fail for ICMP because of a
|
||||||
|
* broken SELinux policy, see icmp_tap_handler().
|
||||||
*/
|
*/
|
||||||
close(fd);
|
if (proto != IPPROTO_ICMP && proto != IPPROTO_ICMPV6) {
|
||||||
return 0;
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proto == IPPROTO_TCP && listen(fd, 128) < 0) {
|
if (proto == IPPROTO_TCP && listen(fd, 128) < 0) {
|
||||||
|
|
Loading…
Reference in a new issue