Commit 48e5f32d authored by Ondrej Zajicek's avatar Ondrej Zajicek
Browse files

Many changes in I/O and OSPF sockets and packet handling.

I/O:
 - BSD: specify src addr on IP sockets by IP_HDRINCL
 - BSD: specify src addr on UDP sockets by IP_SENDSRCADDR
 - Linux: specify src addr on IP/UDP sockets by IP_PKTINFO
 - IPv6: specify src addr on IP/UDP sockets by IPV6_PKTINFO
 - Alternative SKF_BIND flag for binding to IP address
 - Allows IP/UDP sockets without tx_hook, on these
   sockets a packet is discarded when TX queue is full
 - Use consistently SOL_ for socket layer values.

OSPF:
 - Packet src addr is always explicitly set
 - Support for secondary addresses in BSD
 - Dynamic RX/TX buffers
 - Fixes some minor buffer overruns
 - Interface option 'tx length'
 - Names for vlink pseudoifaces (vlinkX)
 - Vlinks use separate socket for TX
 - Vlinks do not use fixed associated iface
 - Fixes TTL for direct unicast packets
 - Fixes DONTROUTE for OSPF sockets
 - Use ifa->ifname instead of ifa->iface->name
parent f48fa142
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -2212,7 +2212,9 @@ protocol ospf <name> {
			wait <num>;
			dead count <num>;
			dead <num>;
			secondary <switch>;
			rx buffer [normal|large|<num>];
			tx length <num>;
			type [broadcast|bcast|pointopoint|ptp|
				nonbroadcast|nbma|pointomultipoint|ptmp];
			strict nonbroadcast <switch>;
@@ -2419,12 +2421,32 @@ protocol ospf <name> {
	<tag>dead <M>num</M></tag>
	 When the router does not receive any messages from a neighbor in
	 <m/dead/ seconds, it will consider the neighbor down. If both directives
	 <m/dead count/ and <m/dead/ are used, <m/dead/ has precendence.
	 <cf/dead count/ and <cf/dead/ are used, <cf/dead/ has precendence.

	<tag>secondary <M>switch</M></tag>
	On BSD systems, older versions of BIRD supported OSPFv2 only for the
	primary IP address of an interface, other IP ranges on the interface
	were handled as stub networks. Since v1.4.1, regular operation on
	secondary IP addresses is supported, but disabled by default for
	compatibility. This option allows to enable it. The option is a
	transitional measure, will be removed in the next major release as the
	behavior will be changed. On Linux systems, the option is irrelevant, as
	operation on non-primary addresses is already the regular behavior.

	<tag>rx buffer <M>num</M></tag>
	 This sets the size of buffer used for receiving packets. The buffer should
	 be bigger than maximal size of any packets. Value NORMAL (default)
	 means 2*MTU, value LARGE means maximal allowed packet - 65535.
	This option allows to specify the size of buffers used for packet
	processing. The buffer size should be bigger than maximal size of any
	packets. By default, buffers are dynamically resized as needed, but a
	fixed value could be specified. Value <cf/large/ means maximal allowed
	packet size - 65535.

	<tag>tx length <M>num</M></tag>
	Transmitted OSPF messages that contain large amount of information are
	segmented to separate OSPF packets to avoid IP fragmentation. This
	option specifies the soft ceiling for the length of generated OSPF
	packets. Default value is the MTU of the network interface. Note that
	larger OSPF packets may still be generated if underlying OSPF messages
	cannot be splitted (e.g. when one large LSA is propagated).

	<tag>type broadcast|bcast</tag>
	 BIRD detects a type of a connected network automatically, but
+10 −7
Original line number Diff line number Diff line
@@ -157,14 +157,14 @@ rfree(void *res)
{
  resource *r = res;

  if (r)
    {
  if (!r)
    return;

  if (r->n.next)
    rem_node(&r->n);
  r->class->free(r);
  xfree(r);
}
}

/**
 * rdump - dump a resource
@@ -408,6 +408,9 @@ mb_realloc(void *m, unsigned size)
void
mb_free(void *m)
{
  if (!m)
    return;

  struct mblock *b = SKIP_BACK(struct mblock, data, m);
  rfree(b);
}
+16 −2
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@ int sk_open(sock *); /* Open socket */
int sk_send(sock *, unsigned len);	/* Send data, <0=err, >0=ok, 0=sleep */
int sk_send_to(sock *, unsigned len, ip_addr to, unsigned port); /* sk_send to given destination */
void sk_reallocate(sock *);		/* Free and allocate tbuf & rbuf */
void sk_set_rbsize(sock *s, uint val);	/* Resize RX buffer */
void sk_set_tbsize(sock *s, uint val);	/* Resize TX buffer, keeping content */
void sk_set_tbuf(sock *s, void *tbuf);	/* Switch TX buffer, NULL-> return to internal */
void sk_dump_all(void);
int sk_set_ttl(sock *s, int ttl);	/* Set transmit TTL for given socket */
int sk_set_min_ttl(sock *s, int ttl);	/* Set minimal accepted TTL for given socket */
@@ -89,10 +92,13 @@ extern int sk_priority_control; /* Suggested priority for control traffic, shoul

#define SKF_V6ONLY	1	/* Use IPV6_V6ONLY socket option */
#define SKF_LADDR_RX	2	/* Report local address for RX packets */
#define SKF_LADDR_TX	4	/* Allow to specify local address for TX packets */
#define SKF_TTL_RX	8	/* Report TTL / Hop Limit for RX packets */
#define SKF_TTL_RX	4	/* Report TTL / Hop Limit for RX packets */
#define SKF_BIND	8	/* Bind datagram socket to given source address */

#define SKF_THREAD	0x100	/* Socked used in thread, Do not add to main loop */
#define SKF_TRUNCATED	0x200	/* Received packet was truncated, set by IO layer */
#define SKF_HDRINCL	0x400	/* Used internally */
#define SKF_PKTINFO	0x800	/* Used internally */

/*
 *	Socket types		     SA SP DA DP IF  TTL SendTo	(?=may, -=must not, *=must)
@@ -118,6 +124,14 @@ extern int sk_priority_control; /* Suggested priority for control traffic, shoul
 *  call sk_setup_multicast() to enable multicast on that socket,
 *  and then use sk_join_group() and sk_leave_group() to manage
 *  a set of received multicast groups.
 *
 *  For datagram (SK_UDP, SK_IP) sockets, there are two ways to handle
 *  source address. The socket could be bound to it using bind()
 *  syscall, but that also forbids the reception of multicast packets,
 *  or the address could be set on per-packet basis using platform
 *  dependent options (but these are not available in some corner
 *  cases). The first way is used when SKF_BIND is specified, the
 *  second way is used otherwise.
 */

#endif
+1 −1
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ bfd_open_tx_sk(struct bfd_proto *p, ip_addr local, struct iface *ifa)
  sk->tos = IP_PREC_INTERNET_CONTROL;
  sk->priority = sk_priority_control;
  sk->ttl = ifa ? 255 : -1;
  sk->flags = SKF_THREAD;
  sk->flags = SKF_THREAD | SKF_BIND;

#ifdef IPV6
  sk->flags |= SKF_V6ONLY;
+7 −4
Original line number Diff line number Diff line
@@ -131,7 +131,8 @@ CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC, TTL, SECURITY)
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, CHECK, LINK, ONLY, BFD)
CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY, TAG, EXTERNAL)
CF_KEYWORDS(WAIT, DELAY, LSADB, ECMP, LIMIT, WEIGHT, NSSA, TRANSLATOR, STABILITY)
CF_KEYWORDS(GLOBAL, LSID, ROUTER, SELF, INSTANCE, REAL, NETMASK, TX, PRIORITY)
CF_KEYWORDS(GLOBAL, LSID, ROUTER, SELF, INSTANCE, REAL, NETMASK, TX, PRIORITY, LENGTH)
CF_KEYWORDS(SECONDARY)

%type <t> opttext
%type <ld> lsadb_args
@@ -302,14 +303,16 @@ ospf_iface_item:
 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; }
 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; }
 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; }
 | RX BUFFER LARGE { OSPF_PATT->rxbuf = OSPF_RXBUF_LARGE ; } 
 | RX BUFFER NORMAL { OSPF_PATT->rxbuf = OSPF_RXBUF_NORMAL ; } 
 | RX BUFFER expr { OSPF_PATT->rxbuf = $3 ; if (($3 < OSPF_RXBUF_MINSIZE) || ($3 > OSPF_MAX_PKT_SIZE)) cf_error("Buffer size must be in range 256-65535"); } 
 | RX BUFFER NORMAL { OSPF_PATT->rx_buffer = 0; } 
 | RX BUFFER LARGE { OSPF_PATT->rx_buffer = OSPF_MAX_PKT_SIZE; } 
 | RX BUFFER expr { OSPF_PATT->rx_buffer = $3; if (($3 < OSPF_MIN_PKT_SIZE) || ($3 > OSPF_MAX_PKT_SIZE)) cf_error("Buffer size must be in range 256-65535"); }
 | TX tos { OSPF_PATT->tx_tos = $2; }
 | TX PRIORITY expr { OSPF_PATT->tx_priority = $3; }
 | TX LENGTH expr { OSPF_PATT->tx_length = $3; if (($3 < OSPF_MIN_PKT_SIZE) || ($3 > OSPF_MAX_PKT_SIZE)) cf_error("TX length must be in range 256-65535"); }
 | TTL SECURITY bool { OSPF_PATT->ttl_security = $3; }
 | TTL SECURITY TX ONLY { OSPF_PATT->ttl_security = 2; }
 | BFD bool { OSPF_PATT->bfd = $2; cf_check_bfd($2); }
 | SECONDARY bool { OSPF_PATT->bsd_secondary = $2; }
 | password_list
 ;

Loading