blob: 7784700819b3fd81639e482423a1b0af7792cc90 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP network related fucntions
2 Copyright (C) 1999 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "thread.h"
24#include "sockunion.h"
Paul Jakma0df7c912008-07-21 21:02:49 +000025#include "sockopt.h"
paul718e3742002-12-13 20:15:29 +000026#include "memory.h"
27#include "log.h"
28#include "if.h"
29#include "prefix.h"
30#include "command.h"
pauledd7c242003-06-04 13:59:38 +000031#include "privs.h"
Paul Jakma0df7c912008-07-21 21:02:49 +000032#include "linklist.h"
paul718e3742002-12-13 20:15:29 +000033
34#include "bgpd/bgpd.h"
35#include "bgpd/bgp_fsm.h"
36#include "bgpd/bgp_attr.h"
37#include "bgpd/bgp_debug.h"
38#include "bgpd/bgp_network.h"
pauledd7c242003-06-04 13:59:38 +000039
40extern struct zebra_privs_t bgpd_privs;
41
paul718e3742002-12-13 20:15:29 +000042
Paul Jakma0df7c912008-07-21 21:02:49 +000043/*
44 * Set MD5 key for the socket, for the given IPv4 peer address.
45 * If the password is NULL or zero-length, the option will be disabled.
46 */
47static int
48bgp_md5_set_socket (int socket, union sockunion *su, const char *password)
49{
50 int ret = -1;
51 int en = ENOSYS;
52
53 assert (socket >= 0);
54
55#if HAVE_DECL_TCP_MD5SIG
56 ret = sockopt_tcp_signature (socket, su, password);
57 en = errno;
58#endif /* HAVE_TCP_MD5SIG */
59
60 if (ret < 0)
61 zlog (NULL, LOG_WARNING, "can't set TCP_MD5SIG option on socket %d: %s",
62 socket, safe_strerror (en));
63
64 return ret;
65}
66
67/* Helper for bgp_connect */
68static int
69bgp_md5_set_connect (int socket, union sockunion *su, const char *password)
70{
71 int ret = -1;
72
73#if HAVE_DECL_TCP_MD5SIG
74 if ( bgpd_privs.change (ZPRIVS_RAISE) )
75 {
76 zlog_err ("%s: could not raise privs", __func__);
77 return ret;
78 }
79
80 ret = bgp_md5_set_socket (socket, su, password);
81
82 if (bgpd_privs.change (ZPRIVS_LOWER) )
83 zlog_err ("%s: could not lower privs", __func__);
84#endif /* HAVE_TCP_MD5SIG */
85
86 return ret;
87}
88
89int
90bgp_md5_set (struct peer *peer)
91{
92 struct listnode *node;
93 int fret = 0, ret;
94 int *socket;
95
96 if ( bgpd_privs.change (ZPRIVS_RAISE) )
97 {
98 zlog_err ("%s: could not raise privs", __func__);
99 return -1;
100 }
101
102 /* Just set the password on the listen socket(s). Outbound connections
103 * are taken care of in bgp_connect() below.
104 */
105 for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, socket))
106 {
Chris Caputo54a15182009-07-18 05:42:34 +0000107 ret = bgp_md5_set_socket ((int)(long)socket, &peer->su, peer->password);
Paul Jakma0df7c912008-07-21 21:02:49 +0000108 if (ret < 0)
109 fret = ret;
110 }
111 if (bgpd_privs.change (ZPRIVS_LOWER) )
112 zlog_err ("%s: could not lower privs", __func__);
113
114 return fret;
115}
116
paul718e3742002-12-13 20:15:29 +0000117/* Accept bgp connection. */
118static int
119bgp_accept (struct thread *thread)
120{
121 int bgp_sock;
122 int accept_sock;
123 union sockunion su;
124 struct peer *peer;
pauleb821182004-05-01 08:44:08 +0000125 struct peer *peer1;
paul718e3742002-12-13 20:15:29 +0000126 struct bgp *bgp;
127 char buf[SU_ADDRSTRLEN];
128
129 /* Regiser accept thread. */
130 accept_sock = THREAD_FD (thread);
131 bgp = THREAD_ARG (thread);
132
133 if (accept_sock < 0)
134 {
135 zlog_err ("accept_sock is nevative value %d", accept_sock);
136 return -1;
137 }
138 thread_add_read (master, bgp_accept, bgp, accept_sock);
139
140 /* Accept client connection. */
141 bgp_sock = sockunion_accept (accept_sock, &su);
142 if (bgp_sock < 0)
143 {
ajs6099b3b2004-11-20 02:06:59 +0000144 zlog_err ("[Error] BGP socket accept failed (%s)", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000145 return -1;
146 }
147
148 if (BGP_DEBUG (events, EVENTS))
ajs478ba052004-12-08 20:41:23 +0000149 zlog_debug ("[Event] BGP connection from host %s", inet_sutop (&su, buf));
paul718e3742002-12-13 20:15:29 +0000150
151 /* Check remote IP address */
pauleb821182004-05-01 08:44:08 +0000152 peer1 = peer_lookup (bgp, &su);
153 if (! peer1 || peer1->status == Idle)
paul718e3742002-12-13 20:15:29 +0000154 {
155 if (BGP_DEBUG (events, EVENTS))
156 {
pauleb821182004-05-01 08:44:08 +0000157 if (! peer1)
ajs478ba052004-12-08 20:41:23 +0000158 zlog_debug ("[Event] BGP connection IP address %s is not configured",
paul718e3742002-12-13 20:15:29 +0000159 inet_sutop (&su, buf));
160 else
ajs478ba052004-12-08 20:41:23 +0000161 zlog_debug ("[Event] BGP connection IP address %s is Idle state",
paul718e3742002-12-13 20:15:29 +0000162 inet_sutop (&su, buf));
163 }
164 close (bgp_sock);
165 return -1;
166 }
167
168 /* In case of peer is EBGP, we should set TTL for this connection. */
pauleb821182004-05-01 08:44:08 +0000169 if (peer_sort (peer1) == BGP_PEER_EBGP)
170 sockopt_ttl (peer1->su.sa.sa_family, bgp_sock, peer1->ttl);
paul718e3742002-12-13 20:15:29 +0000171
172 if (! bgp)
pauleb821182004-05-01 08:44:08 +0000173 bgp = peer1->bgp;
paul718e3742002-12-13 20:15:29 +0000174
pauleb821182004-05-01 08:44:08 +0000175 /* Make dummy peer until read Open packet. */
176 if (BGP_DEBUG (events, EVENTS))
ajs478ba052004-12-08 20:41:23 +0000177 zlog_debug ("[Event] Make dummy peer structure until read Open packet");
pauleb821182004-05-01 08:44:08 +0000178
179 {
180 char buf[SU_ADDRSTRLEN + 1];
181
182 peer = peer_create_accept (bgp);
183 SET_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER);
184 peer->su = su;
185 peer->fd = bgp_sock;
186 peer->status = Active;
187 peer->local_id = peer1->local_id;
Timo Teräse8eb0002009-02-17 12:14:23 +0200188 peer->v_holdtime = peer1->v_holdtime;
189 peer->v_keepalive = peer1->v_keepalive;
pauleb821182004-05-01 08:44:08 +0000190
191 /* Make peer's address string. */
192 sockunion2str (&su, buf, SU_ADDRSTRLEN);
paule83e2082005-05-19 02:12:25 +0000193 peer->host = XSTRDUP (MTYPE_BGP_PEER_HOST, buf);
pauleb821182004-05-01 08:44:08 +0000194 }
paul718e3742002-12-13 20:15:29 +0000195
196 BGP_EVENT_ADD (peer, TCP_connection_open);
197
198 return 0;
199}
200
201/* BGP socket bind. */
paul94f2b392005-06-28 12:44:16 +0000202static int
paul718e3742002-12-13 20:15:29 +0000203bgp_bind (struct peer *peer)
204{
205#ifdef SO_BINDTODEVICE
206 int ret;
207 struct ifreq ifreq;
208
209 if (! peer->ifname)
210 return 0;
211
212 strncpy ((char *)&ifreq.ifr_name, peer->ifname, sizeof (ifreq.ifr_name));
213
paul98f51632004-10-25 14:19:15 +0000214 if ( bgpd_privs.change (ZPRIVS_RAISE) )
215 zlog_err ("bgp_bind: could not raise privs");
216
pauleb821182004-05-01 08:44:08 +0000217 ret = setsockopt (peer->fd, SOL_SOCKET, SO_BINDTODEVICE,
paul718e3742002-12-13 20:15:29 +0000218 &ifreq, sizeof (ifreq));
paul98f51632004-10-25 14:19:15 +0000219
220 if (bgpd_privs.change (ZPRIVS_LOWER) )
221 zlog_err ("bgp_bind: could not lower privs");
222
paul718e3742002-12-13 20:15:29 +0000223 if (ret < 0)
224 {
225 zlog (peer->log, LOG_INFO, "bind to interface %s failed", peer->ifname);
226 return ret;
227 }
228#endif /* SO_BINDTODEVICE */
229 return 0;
230}
231
paul94f2b392005-06-28 12:44:16 +0000232static int
paul718e3742002-12-13 20:15:29 +0000233bgp_bind_address (int sock, struct in_addr *addr)
234{
235 int ret;
236 struct sockaddr_in local;
237
238 memset (&local, 0, sizeof (struct sockaddr_in));
239 local.sin_family = AF_INET;
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000240#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
paul718e3742002-12-13 20:15:29 +0000241 local.sin_len = sizeof(struct sockaddr_in);
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000242#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
paul718e3742002-12-13 20:15:29 +0000243 memcpy (&local.sin_addr, addr, sizeof (struct in_addr));
244
pauledd7c242003-06-04 13:59:38 +0000245 if ( bgpd_privs.change (ZPRIVS_RAISE) )
246 zlog_err ("bgp_bind_address: could not raise privs");
247
paul718e3742002-12-13 20:15:29 +0000248 ret = bind (sock, (struct sockaddr *)&local, sizeof (struct sockaddr_in));
249 if (ret < 0)
250 ;
pauledd7c242003-06-04 13:59:38 +0000251
252 if (bgpd_privs.change (ZPRIVS_LOWER) )
253 zlog_err ("bgp_bind_address: could not lower privs");
254
paul718e3742002-12-13 20:15:29 +0000255 return 0;
256}
257
paul94f2b392005-06-28 12:44:16 +0000258static struct in_addr *
paul718e3742002-12-13 20:15:29 +0000259bgp_update_address (struct interface *ifp)
260{
261 struct prefix_ipv4 *p;
262 struct connected *connected;
hasso52dc7ee2004-09-23 19:18:23 +0000263 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000264
paul1eb8ef22005-04-07 07:30:20 +0000265 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
paul718e3742002-12-13 20:15:29 +0000266 {
paul718e3742002-12-13 20:15:29 +0000267 p = (struct prefix_ipv4 *) connected->address;
268
269 if (p->family == AF_INET)
270 return &p->prefix;
271 }
272 return NULL;
273}
274
275/* Update source selection. */
paul94f2b392005-06-28 12:44:16 +0000276static void
paul718e3742002-12-13 20:15:29 +0000277bgp_update_source (struct peer *peer)
278{
279 struct interface *ifp;
280 struct in_addr *addr;
281
282 /* Source is specified with interface name. */
283 if (peer->update_if)
284 {
285 ifp = if_lookup_by_name (peer->update_if);
286 if (! ifp)
287 return;
288
289 addr = bgp_update_address (ifp);
290 if (! addr)
291 return;
292
pauleb821182004-05-01 08:44:08 +0000293 bgp_bind_address (peer->fd, addr);
paul718e3742002-12-13 20:15:29 +0000294 }
295
296 /* Source is specified with IP address. */
297 if (peer->update_source)
pauleb821182004-05-01 08:44:08 +0000298 sockunion_bind (peer->fd, peer->update_source, 0, peer->update_source);
paul718e3742002-12-13 20:15:29 +0000299}
300
301/* BGP try to connect to the peer. */
302int
303bgp_connect (struct peer *peer)
304{
305 unsigned int ifindex = 0;
306
307 /* Make socket for the peer. */
pauleb821182004-05-01 08:44:08 +0000308 peer->fd = sockunion_socket (&peer->su);
309 if (peer->fd < 0)
paul718e3742002-12-13 20:15:29 +0000310 return -1;
311
312 /* If we can get socket for the peer, adjest TTL and make connection. */
313 if (peer_sort (peer) == BGP_PEER_EBGP)
pauleb821182004-05-01 08:44:08 +0000314 sockopt_ttl (peer->su.sa.sa_family, peer->fd, peer->ttl);
paul718e3742002-12-13 20:15:29 +0000315
pauleb821182004-05-01 08:44:08 +0000316 sockopt_reuseaddr (peer->fd);
317 sockopt_reuseport (peer->fd);
Paul Jakma0df7c912008-07-21 21:02:49 +0000318
Stephen Hemminger1423c802008-08-14 17:59:25 +0100319#ifdef IPTOS_PREC_INTERNETCONTROL
320 if (sockunion_family (&peer->su) == AF_INET)
321 setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL);
322#endif
323
Paul Jakma0df7c912008-07-21 21:02:49 +0000324 if (peer->password)
325 bgp_md5_set_connect (peer->fd, &peer->su, peer->password);
paul718e3742002-12-13 20:15:29 +0000326
327 /* Bind socket. */
328 bgp_bind (peer);
329
330 /* Update source bind. */
331 bgp_update_source (peer);
332
333#ifdef HAVE_IPV6
334 if (peer->ifname)
335 ifindex = if_nametoindex (peer->ifname);
336#endif /* HAVE_IPV6 */
337
338 if (BGP_DEBUG (events, EVENTS))
ajs478ba052004-12-08 20:41:23 +0000339 plog_debug (peer->log, "%s [Event] Connect start to %s fd %d",
pauleb821182004-05-01 08:44:08 +0000340 peer->host, peer->host, peer->fd);
paul718e3742002-12-13 20:15:29 +0000341
342 /* Connect to the remote peer. */
pauleb821182004-05-01 08:44:08 +0000343 return sockunion_connect (peer->fd, &peer->su, htons (peer->port), ifindex);
paul718e3742002-12-13 20:15:29 +0000344}
345
346/* After TCP connection is established. Get local address and port. */
347void
348bgp_getsockname (struct peer *peer)
349{
350 if (peer->su_local)
351 {
paul22db9de2005-05-19 01:50:11 +0000352 sockunion_free (peer->su_local);
paul718e3742002-12-13 20:15:29 +0000353 peer->su_local = NULL;
354 }
355
356 if (peer->su_remote)
357 {
paul22db9de2005-05-19 01:50:11 +0000358 sockunion_free (peer->su_remote);
paul718e3742002-12-13 20:15:29 +0000359 peer->su_remote = NULL;
360 }
361
pauleb821182004-05-01 08:44:08 +0000362 peer->su_local = sockunion_getsockname (peer->fd);
363 peer->su_remote = sockunion_getpeername (peer->fd);
paul718e3742002-12-13 20:15:29 +0000364
365 bgp_nexthop_set (peer->su_local, peer->su_remote, &peer->nexthop, peer);
366}
367
368/* IPv6 supported version of BGP server socket setup. */
369#if defined (HAVE_IPV6) && ! defined (NRL)
370int
Paul Jakma3a02d1f2007-11-01 14:29:11 +0000371bgp_socket (struct bgp *bgp, unsigned short port, char *address)
paul718e3742002-12-13 20:15:29 +0000372{
gdt10d60ad2003-12-23 17:34:39 +0000373 int ret, en;
paul718e3742002-12-13 20:15:29 +0000374 struct addrinfo req;
375 struct addrinfo *ainfo;
376 struct addrinfo *ainfo_save;
377 int sock = 0;
378 char port_str[BUFSIZ];
379
380 memset (&req, 0, sizeof (struct addrinfo));
381
382 req.ai_flags = AI_PASSIVE;
383 req.ai_family = AF_UNSPEC;
384 req.ai_socktype = SOCK_STREAM;
Paul Jakma90b68762008-01-29 17:26:34 +0000385 snprintf (port_str, sizeof(port_str), "%d", port);
paul718e3742002-12-13 20:15:29 +0000386 port_str[sizeof (port_str) - 1] = '\0';
387
Paul Jakma3a02d1f2007-11-01 14:29:11 +0000388 ret = getaddrinfo (address, port_str, &req, &ainfo);
paul718e3742002-12-13 20:15:29 +0000389 if (ret != 0)
390 {
391 zlog_err ("getaddrinfo: %s", gai_strerror (ret));
392 return -1;
393 }
394
395 ainfo_save = ainfo;
396
397 do
398 {
399 if (ainfo->ai_family != AF_INET && ainfo->ai_family != AF_INET6)
400 continue;
401
402 sock = socket (ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);
403 if (sock < 0)
404 {
ajs6099b3b2004-11-20 02:06:59 +0000405 zlog_err ("socket: %s", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000406 continue;
407 }
408
409 sockopt_reuseaddr (sock);
410 sockopt_reuseport (sock);
pauledd7c242003-06-04 13:59:38 +0000411
Stephen Hemminger1423c802008-08-14 17:59:25 +0100412#ifdef IPTOS_PREC_INTERNETCONTROL
413 if (ainfo->ai_family == AF_INET)
414 setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
415#endif
416
Stephen Hemmingere9a36702008-08-24 20:36:51 -0400417#ifdef IPV6_V6ONLY
418 /* Want only IPV6 on ipv6 socket (not mapped addresses) */
419 if (ainfo->ai_family == AF_INET6) {
420 int on = 1;
421 setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
422 (void *) &on, sizeof (on));
423 }
424#endif
425
pauledd7c242003-06-04 13:59:38 +0000426 if (bgpd_privs.change (ZPRIVS_RAISE) )
427 zlog_err ("bgp_socket: could not raise privs");
paul718e3742002-12-13 20:15:29 +0000428
429 ret = bind (sock, ainfo->ai_addr, ainfo->ai_addrlen);
gdt10d60ad2003-12-23 17:34:39 +0000430 en = errno;
431 if (bgpd_privs.change (ZPRIVS_LOWER) )
432 zlog_err ("bgp_bind_address: could not lower privs");
433
paul718e3742002-12-13 20:15:29 +0000434 if (ret < 0)
435 {
ajs6099b3b2004-11-20 02:06:59 +0000436 zlog_err ("bind: %s", safe_strerror (en));
gdt10d60ad2003-12-23 17:34:39 +0000437 close(sock);
paul718e3742002-12-13 20:15:29 +0000438 continue;
439 }
pauledd7c242003-06-04 13:59:38 +0000440
paul718e3742002-12-13 20:15:29 +0000441 ret = listen (sock, 3);
442 if (ret < 0)
443 {
ajs6099b3b2004-11-20 02:06:59 +0000444 zlog_err ("listen: %s", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000445 close (sock);
446 continue;
447 }
Paul Jakma0df7c912008-07-21 21:02:49 +0000448
Chris Caputo54a15182009-07-18 05:42:34 +0000449 listnode_add (bm->listen_sockets, (void *)(long)sock);
paul718e3742002-12-13 20:15:29 +0000450 thread_add_read (master, bgp_accept, bgp, sock);
451 }
452 while ((ainfo = ainfo->ai_next) != NULL);
453
454 freeaddrinfo (ainfo_save);
455
456 return sock;
457}
458#else
459/* Traditional IPv4 only version. */
460int
Paul Jakma3a02d1f2007-11-01 14:29:11 +0000461bgp_socket (struct bgp *bgp, unsigned short port, char *address)
paul718e3742002-12-13 20:15:29 +0000462{
463 int sock;
464 int socklen;
465 struct sockaddr_in sin;
hasso4a1a2712004-02-12 15:41:38 +0000466 int ret, en;
paul718e3742002-12-13 20:15:29 +0000467
468 sock = socket (AF_INET, SOCK_STREAM, 0);
469 if (sock < 0)
470 {
ajs6099b3b2004-11-20 02:06:59 +0000471 zlog_err ("socket: %s", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000472 return sock;
473 }
474
475 sockopt_reuseaddr (sock);
476 sockopt_reuseport (sock);
477
Stephen Hemminger1423c802008-08-14 17:59:25 +0100478#ifdef IPTOS_PREC_INTERNETCONTROL
479 setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
480#endif
481
paul718e3742002-12-13 20:15:29 +0000482 memset (&sin, 0, sizeof (struct sockaddr_in));
483
484 sin.sin_family = AF_INET;
485 sin.sin_port = htons (port);
486 socklen = sizeof (struct sockaddr_in);
Paul Jakma3a02d1f2007-11-01 14:29:11 +0000487
Paul Jakma90b68762008-01-29 17:26:34 +0000488 if (address && ((ret = inet_aton(address, &sin.sin_addr)) < 1))
Paul Jakma3a02d1f2007-11-01 14:29:11 +0000489 {
Paul Jakma90b68762008-01-29 17:26:34 +0000490 zlog_err("bgp_socket: could not parse ip address %s: %s",
491 address, safe_strerror (errno));
Paul Jakma3a02d1f2007-11-01 14:29:11 +0000492 return ret;
493 }
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000494#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
paul718e3742002-12-13 20:15:29 +0000495 sin.sin_len = socklen;
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000496#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
paul718e3742002-12-13 20:15:29 +0000497
pauledd7c242003-06-04 13:59:38 +0000498 if ( bgpd_privs.change (ZPRIVS_RAISE) )
499 zlog_err ("bgp_socket: could not raise privs");
500
paul718e3742002-12-13 20:15:29 +0000501 ret = bind (sock, (struct sockaddr *) &sin, socklen);
gdt10d60ad2003-12-23 17:34:39 +0000502 en = errno;
503
504 if (bgpd_privs.change (ZPRIVS_LOWER) )
505 zlog_err ("bgp_socket: could not lower privs");
506
paul718e3742002-12-13 20:15:29 +0000507 if (ret < 0)
508 {
ajs6099b3b2004-11-20 02:06:59 +0000509 zlog_err ("bind: %s", safe_strerror (en));
paul718e3742002-12-13 20:15:29 +0000510 close (sock);
511 return ret;
512 }
pauledd7c242003-06-04 13:59:38 +0000513
paul718e3742002-12-13 20:15:29 +0000514 ret = listen (sock, 3);
515 if (ret < 0)
516 {
ajs6099b3b2004-11-20 02:06:59 +0000517 zlog_err ("listen: %s", safe_strerror (errno));
paul718e3742002-12-13 20:15:29 +0000518 close (sock);
519 return ret;
520 }
521
Chris Caputo54a15182009-07-18 05:42:34 +0000522 listnode_add (bm->listen_sockets, (void *)(long)sock);
paul718e3742002-12-13 20:15:29 +0000523 thread_add_read (bm->master, bgp_accept, bgp, sock);
524
525 return sock;
526}
527#endif /* HAVE_IPV6 && !NRL */