Revision 9c89560e

View differences:

lib/socket.h
103 103
#define SKF_LADDR_RX	0x04	/* Report local address for RX packets */
104 104
#define SKF_TTL_RX	0x08	/* Report TTL / Hop Limit for RX packets */
105 105
#define SKF_BIND	0x10	/* Bind datagram socket to given source address */
106
#define SKF_HIGH_PORT	0x20	/* Choose port from high range if possible */
106 107

  
107 108
#define SKF_THREAD	0x100	/* Socked used in thread, Do not add to main loop */
108 109
#define SKF_TRUNCATED	0x200	/* Received packet was truncated, set by IO layer */
proto/bfd/packets.c
231 231
  sk->tos = IP_PREC_INTERNET_CONTROL;
232 232
  sk->priority = sk_priority_control;
233 233
  sk->ttl = ifa ? 255 : -1;
234
  sk->flags = SKF_THREAD | SKF_BIND;
234
  sk->flags = SKF_THREAD | SKF_BIND | SKF_HIGH_PORT;
235 235

  
236 236
#ifdef IPV6
237 237
  sk->flags |= SKF_V6ONLY;
sysdep/unix/io.c
1305 1305
    log(L_ERR "SOCK: Incoming connection: %s%#m", t->err);
1306 1306

  
1307 1307
    /* FIXME: handle it better in rfree() */
1308
    close(t->fd);	
1308
    close(t->fd);
1309 1309
    t->fd = -1;
1310 1310
    rfree(t);
1311 1311
    return 1;
......
1348 1348
    bind_addr = s->saddr;
1349 1349
    do_bind = bind_port || ipa_nonzero(bind_addr);
1350 1350
    break;
1351
  
1351

  
1352 1352
  case SK_UDP:
1353 1353
    fd = socket(af, SOCK_DGRAM, IPPROTO_UDP);
1354 1354
    bind_port = s->sport;
......
1399 1399
      }
1400 1400
#endif
1401 1401
    }
1402
#ifdef IP_PORTRANGE
1403
    else if (s->flags & SKF_HIGH_PORT)
1404
    {
1405
      int range = IP_PORTRANGE_HIGH;
1406
      if (setsockopt(fd, IPPROTO_IP, IP_PORTRANGE, &range, sizeof(range)) < 0)
1407
        log(L_WARN "Socket error: %s%#m", "IP_PORTRANGE");
1408
    }
1409
#endif
1402 1410

  
1403 1411
    sockaddr_fill(&sa, af, bind_addr, s->iface, bind_port);
1404 1412
    if (bind(fd, &sa.sa, SA_LEN(sa)) < 0)
......
1661 1669

  
1662 1670
 redo:
1663 1671
  rv = select(s->fd+1, &rd, &wr, NULL, &timo);
1664
  
1672

  
1665 1673
  if ((rv < 0) && (errno == EINTR || errno == EAGAIN))
1666 1674
    goto redo;
1667 1675

  
......
2026 2034
    die("I found another BIRD running.");
2027 2035
  close(fd);
2028 2036
}
2029

  
2030

  

Also available in: Unified diff