]>
Commit | Line | Data |
---|---|---|
7fc02572 RW |
1 | /* |
2 | * Copyright (C) 2016 by Open Source Routing. | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
7fc02572 RW |
19 | */ |
20 | ||
d3e2c74a | 21 | #include <zebra.h> |
ddfeb486 DL |
22 | |
23 | #ifdef OPEN_BSD | |
24 | ||
d3e2c74a RW |
25 | #include <netmpls/mpls.h> |
26 | #include "zebra/rt.h" | |
27 | #include "zebra/zebra_mpls.h" | |
28 | #include "zebra/debug.h" | |
29 | ||
30 | #include "privs.h" | |
31 | #include "prefix.h" | |
32 | #include "interface.h" | |
33 | #include "log.h" | |
174482ef | 34 | #include "lib_errors.h" |
d3e2c74a RW |
35 | |
36 | extern struct zebra_privs_t zserv_privs; | |
37 | ||
38 | struct { | |
d7c0a89a | 39 | uint32_t rtseq; |
d62a17ae | 40 | int fd; |
d42127da | 41 | int ioctl_fd; |
d3e2c74a RW |
42 | } kr_state; |
43 | ||
d62a17ae | 44 | static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label, |
45 | zebra_nhlfe_t *nhlfe) | |
d3e2c74a | 46 | { |
d62a17ae | 47 | struct iovec iov[5]; |
48 | struct rt_msghdr hdr; | |
49 | struct sockaddr_mpls sa_label_in, sa_label_out; | |
50 | struct sockaddr_in nexthop; | |
51 | int iovcnt = 0; | |
52 | int ret; | |
53 | ||
54 | if (IS_ZEBRA_DEBUG_KERNEL) | |
55 | zlog_debug("%s: 0x%x, label=%u", __func__, action, in_label); | |
56 | ||
57 | /* initialize header */ | |
58 | memset(&hdr, 0, sizeof(hdr)); | |
59 | hdr.rtm_version = RTM_VERSION; | |
60 | ||
61 | hdr.rtm_type = action; | |
62 | hdr.rtm_flags = RTF_UP; | |
63 | hdr.rtm_fmask = RTF_MPLS; | |
64 | hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */ | |
65 | hdr.rtm_msglen = sizeof(hdr); | |
66 | hdr.rtm_hdrlen = sizeof(struct rt_msghdr); | |
67 | hdr.rtm_priority = 0; | |
68 | /* adjust iovec */ | |
69 | iov[iovcnt].iov_base = &hdr; | |
70 | iov[iovcnt++].iov_len = sizeof(hdr); | |
71 | ||
72 | /* in label */ | |
73 | memset(&sa_label_in, 0, sizeof(sa_label_in)); | |
74 | sa_label_in.smpls_len = sizeof(sa_label_in); | |
75 | sa_label_in.smpls_family = AF_MPLS; | |
76 | sa_label_in.smpls_label = htonl(in_label << MPLS_LABEL_OFFSET); | |
77 | /* adjust header */ | |
78 | hdr.rtm_flags |= RTF_MPLS | RTF_MPATH; | |
79 | hdr.rtm_addrs |= RTA_DST; | |
80 | hdr.rtm_msglen += sizeof(sa_label_in); | |
81 | /* adjust iovec */ | |
82 | iov[iovcnt].iov_base = &sa_label_in; | |
83 | iov[iovcnt++].iov_len = sizeof(sa_label_in); | |
84 | ||
85 | /* nexthop */ | |
86 | memset(&nexthop, 0, sizeof(nexthop)); | |
87 | nexthop.sin_len = sizeof(nexthop); | |
88 | nexthop.sin_family = AF_INET; | |
89 | nexthop.sin_addr = nhlfe->nexthop->gate.ipv4; | |
90 | /* adjust header */ | |
91 | hdr.rtm_flags |= RTF_GATEWAY; | |
92 | hdr.rtm_addrs |= RTA_GATEWAY; | |
93 | hdr.rtm_msglen += sizeof(nexthop); | |
94 | /* adjust iovec */ | |
95 | iov[iovcnt].iov_base = &nexthop; | |
96 | iov[iovcnt++].iov_len = sizeof(nexthop); | |
97 | ||
98 | /* If action is RTM_DELETE we have to get rid of MPLS infos */ | |
99 | if (action != RTM_DELETE) { | |
100 | memset(&sa_label_out, 0, sizeof(sa_label_out)); | |
101 | sa_label_out.smpls_len = sizeof(sa_label_out); | |
102 | sa_label_out.smpls_family = AF_MPLS; | |
103 | sa_label_out.smpls_label = | |
104 | htonl(nhlfe->nexthop->nh_label->label[0] | |
105 | << MPLS_LABEL_OFFSET); | |
106 | /* adjust header */ | |
107 | hdr.rtm_addrs |= RTA_SRC; | |
108 | hdr.rtm_flags |= RTF_MPLS; | |
109 | hdr.rtm_msglen += sizeof(sa_label_out); | |
110 | /* adjust iovec */ | |
111 | iov[iovcnt].iov_base = &sa_label_out; | |
112 | iov[iovcnt++].iov_len = sizeof(sa_label_out); | |
113 | ||
114 | if (nhlfe->nexthop->nh_label->label[0] == MPLS_LABEL_IMPLNULL) | |
115 | hdr.rtm_mpls = MPLS_OP_POP; | |
116 | else | |
117 | hdr.rtm_mpls = MPLS_OP_SWAP; | |
118 | } | |
119 | ||
120 | if (zserv_privs.change(ZPRIVS_RAISE)) | |
af4c2728 | 121 | flog_err(LIB_ERR_PRIVILEGES, "Can't raise privileges"); |
d62a17ae | 122 | ret = writev(kr_state.fd, iov, iovcnt); |
123 | if (zserv_privs.change(ZPRIVS_LOWER)) | |
af4c2728 | 124 | flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges"); |
d62a17ae | 125 | |
126 | if (ret == -1) | |
09c866e3 QY |
127 | flog_err_sys(LIB_ERR_SOCKET, "%s: %s", __func__, |
128 | safe_strerror(errno)); | |
d62a17ae | 129 | |
130 | return ret; | |
e07486ce RW |
131 | } |
132 | ||
133 | #if !defined(ROUNDUP) | |
d62a17ae | 134 | #define ROUNDUP(a) \ |
135 | (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) | |
e07486ce RW |
136 | #endif |
137 | ||
d62a17ae | 138 | static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label, |
139 | zebra_nhlfe_t *nhlfe) | |
e07486ce | 140 | { |
d62a17ae | 141 | struct iovec iov[5]; |
142 | struct rt_msghdr hdr; | |
143 | struct sockaddr_mpls sa_label_in, sa_label_out; | |
144 | struct pad { | |
145 | struct sockaddr_in6 addr; | |
146 | char pad[sizeof(long)]; /* thank you IPv6 */ | |
147 | } nexthop; | |
148 | int iovcnt = 0; | |
149 | int ret; | |
150 | ||
151 | if (IS_ZEBRA_DEBUG_KERNEL) | |
152 | zlog_debug("%s: 0x%x, label=%u", __func__, action, in_label); | |
153 | ||
154 | /* initialize header */ | |
155 | memset(&hdr, 0, sizeof(hdr)); | |
156 | hdr.rtm_version = RTM_VERSION; | |
157 | ||
158 | hdr.rtm_type = action; | |
159 | hdr.rtm_flags = RTF_UP; | |
160 | hdr.rtm_fmask = RTF_MPLS; | |
161 | hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */ | |
162 | hdr.rtm_msglen = sizeof(hdr); | |
163 | hdr.rtm_hdrlen = sizeof(struct rt_msghdr); | |
164 | hdr.rtm_priority = 0; | |
165 | /* adjust iovec */ | |
166 | iov[iovcnt].iov_base = &hdr; | |
167 | iov[iovcnt++].iov_len = sizeof(hdr); | |
168 | ||
169 | /* in label */ | |
170 | memset(&sa_label_in, 0, sizeof(sa_label_in)); | |
171 | sa_label_in.smpls_len = sizeof(sa_label_in); | |
172 | sa_label_in.smpls_family = AF_MPLS; | |
173 | sa_label_in.smpls_label = htonl(in_label << MPLS_LABEL_OFFSET); | |
174 | /* adjust header */ | |
175 | hdr.rtm_flags |= RTF_MPLS | RTF_MPATH; | |
176 | hdr.rtm_addrs |= RTA_DST; | |
177 | hdr.rtm_msglen += sizeof(sa_label_in); | |
178 | /* adjust iovec */ | |
179 | iov[iovcnt].iov_base = &sa_label_in; | |
180 | iov[iovcnt++].iov_len = sizeof(sa_label_in); | |
181 | ||
182 | /* nexthop */ | |
183 | memset(&nexthop, 0, sizeof(nexthop)); | |
184 | nexthop.addr.sin6_len = sizeof(struct sockaddr_in6); | |
185 | nexthop.addr.sin6_family = AF_INET6; | |
186 | nexthop.addr.sin6_addr = nhlfe->nexthop->gate.ipv6; | |
187 | if (IN6_IS_ADDR_LINKLOCAL(&nexthop.addr.sin6_addr)) { | |
188 | uint16_t tmp16; | |
189 | struct sockaddr_in6 *sin6 = &nexthop.addr; | |
190 | ||
191 | nexthop.addr.sin6_scope_id = nhlfe->nexthop->ifindex; | |
192 | ||
193 | memcpy(&tmp16, &sin6->sin6_addr.s6_addr[2], sizeof(tmp16)); | |
194 | tmp16 = htons(sin6->sin6_scope_id); | |
195 | memcpy(&sin6->sin6_addr.s6_addr[2], &tmp16, sizeof(tmp16)); | |
196 | sin6->sin6_scope_id = 0; | |
197 | } | |
198 | ||
199 | /* adjust header */ | |
200 | hdr.rtm_flags |= RTF_GATEWAY; | |
201 | hdr.rtm_addrs |= RTA_GATEWAY; | |
202 | hdr.rtm_msglen += ROUNDUP(sizeof(struct sockaddr_in6)); | |
203 | /* adjust iovec */ | |
204 | iov[iovcnt].iov_base = &nexthop; | |
205 | iov[iovcnt++].iov_len = ROUNDUP(sizeof(struct sockaddr_in6)); | |
206 | ||
207 | /* If action is RTM_DELETE we have to get rid of MPLS infos */ | |
208 | if (action != RTM_DELETE) { | |
209 | memset(&sa_label_out, 0, sizeof(sa_label_out)); | |
210 | sa_label_out.smpls_len = sizeof(sa_label_out); | |
211 | sa_label_out.smpls_family = AF_MPLS; | |
212 | sa_label_out.smpls_label = | |
213 | htonl(nhlfe->nexthop->nh_label->label[0] | |
214 | << MPLS_LABEL_OFFSET); | |
215 | /* adjust header */ | |
216 | hdr.rtm_addrs |= RTA_SRC; | |
217 | hdr.rtm_flags |= RTF_MPLS; | |
218 | hdr.rtm_msglen += sizeof(sa_label_out); | |
219 | /* adjust iovec */ | |
220 | iov[iovcnt].iov_base = &sa_label_out; | |
221 | iov[iovcnt++].iov_len = sizeof(sa_label_out); | |
222 | ||
223 | if (nhlfe->nexthop->nh_label->label[0] == MPLS_LABEL_IMPLNULL) | |
224 | hdr.rtm_mpls = MPLS_OP_POP; | |
225 | else | |
226 | hdr.rtm_mpls = MPLS_OP_SWAP; | |
227 | } | |
228 | ||
229 | if (zserv_privs.change(ZPRIVS_RAISE)) | |
af4c2728 | 230 | flog_err(LIB_ERR_PRIVILEGES, "Can't raise privileges"); |
d62a17ae | 231 | ret = writev(kr_state.fd, iov, iovcnt); |
232 | if (zserv_privs.change(ZPRIVS_LOWER)) | |
af4c2728 | 233 | flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges"); |
d62a17ae | 234 | |
235 | if (ret == -1) | |
09c866e3 QY |
236 | flog_err_sys(LIB_ERR_SOCKET, "%s: %s", __func__, |
237 | safe_strerror(errno)); | |
d62a17ae | 238 | |
239 | return ret; | |
d3e2c74a RW |
240 | } |
241 | ||
d62a17ae | 242 | static int kernel_lsp_cmd(int action, zebra_lsp_t *lsp) |
d3e2c74a | 243 | { |
d62a17ae | 244 | zebra_nhlfe_t *nhlfe; |
245 | struct nexthop *nexthop = NULL; | |
246 | unsigned int nexthop_num = 0; | |
247 | ||
248 | for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) { | |
249 | nexthop = nhlfe->nexthop; | |
250 | if (!nexthop) | |
251 | continue; | |
252 | ||
253 | if (nexthop_num >= multipath_num) | |
254 | break; | |
255 | ||
256 | if (((action == RTM_ADD || action == RTM_CHANGE) | |
257 | && (CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_SELECTED) | |
258 | && CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))) | |
259 | || (action == RTM_DELETE | |
260 | && (CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED) | |
261 | && CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)))) { | |
5e8c8947 RW |
262 | if (nhlfe->nexthop->nh_label->num_labels > 1) { |
263 | zlog_warn( | |
264 | "%s: can't push %u labels at once " | |
265 | "(maximum is 1)", | |
266 | __func__, | |
267 | nhlfe->nexthop->nh_label->num_labels); | |
268 | continue; | |
269 | } | |
270 | ||
d62a17ae | 271 | nexthop_num++; |
272 | ||
273 | switch (NHLFE_FAMILY(nhlfe)) { | |
274 | case AF_INET: | |
275 | kernel_send_rtmsg_v4(action, lsp->ile.in_label, | |
276 | nhlfe); | |
277 | break; | |
278 | case AF_INET6: | |
279 | kernel_send_rtmsg_v6(action, lsp->ile.in_label, | |
280 | nhlfe); | |
281 | break; | |
282 | default: | |
283 | break; | |
284 | } | |
d62a17ae | 285 | } |
286 | } | |
287 | ||
288 | return (0); | |
d3e2c74a RW |
289 | } |
290 | ||
7c5d0e18 | 291 | enum dp_req_result kernel_add_lsp(zebra_lsp_t *lsp) |
d3e2c74a | 292 | { |
d62a17ae | 293 | int ret; |
c4c8dec0 | 294 | |
4a83e7a0 | 295 | if (!lsp || !lsp->best_nhlfe) { // unexpected |
215181cb | 296 | kernel_lsp_pass_fail(lsp, DP_INSTALL_FAILURE); |
7c5d0e18 | 297 | return DP_REQUEST_FAILURE; |
4a83e7a0 | 298 | } |
d3e2c74a | 299 | |
d62a17ae | 300 | ret = kernel_lsp_cmd(RTM_ADD, lsp); |
c4c8dec0 | 301 | |
4a83e7a0 | 302 | kernel_lsp_pass_fail(lsp, |
215181cb DS |
303 | (!ret) ? DP_INSTALL_SUCCESS |
304 | : DP_INSTALL_FAILURE); | |
7c5d0e18 DS |
305 | |
306 | return DP_REQUEST_SUCCESS; | |
d3e2c74a RW |
307 | } |
308 | ||
7c5d0e18 | 309 | enum dp_req_result kernel_upd_lsp(zebra_lsp_t *lsp) |
d3e2c74a | 310 | { |
d62a17ae | 311 | int ret; |
c4c8dec0 | 312 | |
4a83e7a0 | 313 | if (!lsp || !lsp->best_nhlfe) { // unexpected |
215181cb | 314 | kernel_lsp_pass_fail(lsp, DP_INSTALL_FAILURE); |
7c5d0e18 | 315 | return DP_REQUEST_FAILURE; |
4a83e7a0 | 316 | } |
d3e2c74a | 317 | |
d62a17ae | 318 | ret = kernel_lsp_cmd(RTM_CHANGE, lsp); |
c4c8dec0 | 319 | |
4a83e7a0 | 320 | kernel_lsp_pass_fail(lsp, |
215181cb DS |
321 | (!ret) ? DP_INSTALL_SUCCESS |
322 | : DP_INSTALL_FAILURE); | |
7c5d0e18 | 323 | return DP_REQUEST_SUCCESS; |
d3e2c74a RW |
324 | } |
325 | ||
7c5d0e18 | 326 | enum dp_req_result kernel_del_lsp(zebra_lsp_t *lsp) |
d3e2c74a | 327 | { |
d62a17ae | 328 | int ret; |
c4c8dec0 | 329 | |
4a83e7a0 | 330 | if (!lsp) { // unexpected |
215181cb | 331 | kernel_lsp_pass_fail(lsp, DP_DELETE_FAILURE); |
7c5d0e18 | 332 | return DP_REQUEST_FAILURE; |
4a83e7a0 | 333 | } |
d3e2c74a | 334 | |
4a83e7a0 | 335 | if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) { |
215181cb | 336 | kernel_lsp_pass_fail(lsp, DP_DELETE_FAILURE); |
7c5d0e18 | 337 | return DP_REQUEST_FAILURE; |
4a83e7a0 | 338 | } |
c4c8dec0 | 339 | |
d62a17ae | 340 | ret = kernel_lsp_cmd(RTM_DELETE, lsp); |
c4c8dec0 | 341 | |
4a83e7a0 | 342 | kernel_lsp_pass_fail(lsp, |
215181cb DS |
343 | (!ret) ? DP_DELETE_SUCCESS |
344 | : DP_DELETE_FAILURE); | |
7c5d0e18 DS |
345 | |
346 | return DP_REQUEST_SUCCESS; | |
d3e2c74a RW |
347 | } |
348 | ||
d42127da RW |
349 | static int kmpw_install(struct zebra_pw *pw) |
350 | { | |
351 | struct ifreq ifr; | |
352 | struct ifmpwreq imr; | |
353 | struct sockaddr_storage ss; | |
354 | struct sockaddr_in *sa_in = (struct sockaddr_in *)&ss; | |
355 | struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)&ss; | |
356 | ||
357 | memset(&imr, 0, sizeof(imr)); | |
358 | switch (pw->type) { | |
359 | case PW_TYPE_ETHERNET: | |
360 | imr.imr_type = IMR_TYPE_ETHERNET; | |
361 | break; | |
362 | case PW_TYPE_ETHERNET_TAGGED: | |
363 | imr.imr_type = IMR_TYPE_ETHERNET_TAGGED; | |
364 | break; | |
365 | default: | |
43e52561 QY |
366 | zlog_warn("%s: unhandled pseudowire type (%#X)", __func__, |
367 | pw->type); | |
d42127da RW |
368 | return -1; |
369 | } | |
370 | ||
371 | if (pw->flags & F_PSEUDOWIRE_CWORD) | |
372 | imr.imr_flags |= IMR_FLAG_CONTROLWORD; | |
373 | ||
374 | /* pseudowire nexthop */ | |
375 | memset(&ss, 0, sizeof(ss)); | |
376 | switch (pw->af) { | |
377 | case AF_INET: | |
378 | sa_in->sin_family = AF_INET; | |
379 | sa_in->sin_len = sizeof(struct sockaddr_in); | |
380 | sa_in->sin_addr = pw->nexthop.ipv4; | |
381 | break; | |
382 | case AF_INET6: | |
383 | sa_in6->sin6_family = AF_INET6; | |
384 | sa_in6->sin6_len = sizeof(struct sockaddr_in6); | |
385 | sa_in6->sin6_addr = pw->nexthop.ipv6; | |
386 | break; | |
387 | default: | |
43e52561 QY |
388 | zlog_warn("%s: unhandled pseudowire address-family (%u)", |
389 | __func__, pw->af); | |
d42127da RW |
390 | return -1; |
391 | } | |
392 | memcpy(&imr.imr_nexthop, (struct sockaddr *)&ss, | |
393 | sizeof(imr.imr_nexthop)); | |
394 | ||
395 | /* pseudowire local/remote labels */ | |
396 | imr.imr_lshim.shim_label = pw->local_label; | |
397 | imr.imr_rshim.shim_label = pw->remote_label; | |
398 | ||
399 | /* ioctl */ | |
400 | memset(&ifr, 0, sizeof(ifr)); | |
401 | strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name)); | |
402 | ifr.ifr_data = (caddr_t)&imr; | |
403 | if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) { | |
09c866e3 QY |
404 | flog_err_sys(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s", |
405 | safe_strerror(errno)); | |
d42127da RW |
406 | return -1; |
407 | } | |
408 | ||
409 | return 0; | |
410 | } | |
411 | ||
412 | static int kmpw_uninstall(struct zebra_pw *pw) | |
413 | { | |
414 | struct ifreq ifr; | |
415 | struct ifmpwreq imr; | |
416 | ||
417 | memset(&ifr, 0, sizeof(ifr)); | |
418 | memset(&imr, 0, sizeof(imr)); | |
419 | strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name)); | |
420 | ifr.ifr_data = (caddr_t)&imr; | |
421 | if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) { | |
09c866e3 QY |
422 | flog_err_sys(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s", |
423 | safe_strerror(errno)); | |
d42127da RW |
424 | return -1; |
425 | } | |
426 | ||
427 | return 0; | |
428 | } | |
429 | ||
d3e2c74a | 430 | #define MAX_RTSOCK_BUF 128 * 1024 |
d62a17ae | 431 | int mpls_kernel_init(void) |
d3e2c74a | 432 | { |
d62a17ae | 433 | int rcvbuf, default_rcvbuf; |
434 | socklen_t optlen; | |
435 | ||
436 | if ((kr_state.fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) { | |
437 | zlog_warn("%s: socket", __func__); | |
438 | return -1; | |
439 | } | |
440 | ||
d42127da RW |
441 | if ((kr_state.ioctl_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) |
442 | == -1) { | |
443 | zlog_warn("%s: ioctl socket", __func__); | |
444 | return -1; | |
445 | } | |
446 | ||
d62a17ae | 447 | /* grow receive buffer, don't wanna miss messages */ |
448 | optlen = sizeof(default_rcvbuf); | |
449 | if (getsockopt(kr_state.fd, SOL_SOCKET, SO_RCVBUF, &default_rcvbuf, | |
450 | &optlen) | |
451 | == -1) | |
452 | zlog_warn("kr_init getsockopt SOL_SOCKET SO_RCVBUF"); | |
453 | else | |
454 | for (rcvbuf = MAX_RTSOCK_BUF; | |
455 | rcvbuf > default_rcvbuf | |
456 | && setsockopt(kr_state.fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, | |
457 | sizeof(rcvbuf)) | |
458 | == -1 | |
459 | && errno == ENOBUFS; | |
460 | rcvbuf /= 2) | |
461 | ; /* nothing */ | |
462 | ||
463 | kr_state.rtseq = 1; | |
464 | ||
d42127da RW |
465 | /* register hook to install/uninstall pseudowires */ |
466 | hook_register(pw_install, kmpw_install); | |
467 | hook_register(pw_uninstall, kmpw_uninstall); | |
468 | ||
d62a17ae | 469 | return 0; |
d3e2c74a | 470 | } |
ddfeb486 DL |
471 | |
472 | #endif /* OPEN_BSD */ |