| 366 | } |
| 367 | |
| 368 | static int |
| 369 | in6_gre_attach(struct gre_softc *sc) |
| 370 | { |
| 371 | struct grehdr *gh; |
| 372 | int error; |
| 373 | |
| 374 | if (sc->gre_options & GRE_UDPENCAP) { |
| 375 | sc->gre_csumflags = CSUM_UDP_IPV6; |
| 376 | sc->gre_hlen = sizeof(struct greudp6); |
| 377 | sc->gre_oip6.ip6_nxt = IPPROTO_UDP; |
| 378 | gh = &sc->gre_udp6hdr->gi6_gre; |
| 379 | gre_update_udphdr(sc, &sc->gre_udp6, |
| 380 | in6_cksum_pseudo(&sc->gre_oip6, 0, 0, 0)); |
| 381 | } else { |
| 382 | sc->gre_hlen = sizeof(struct greip6); |
| 383 | sc->gre_oip6.ip6_nxt = IPPROTO_GRE; |
| 384 | gh = &sc->gre_ip6hdr->gi6_gre; |
| 385 | } |
| 386 | sc->gre_oip6.ip6_vfc = IPV6_VERSION; |
| 387 | gre_update_hdr(sc, gh); |
| 388 | |
| 389 | /* |
| 390 | * If we return error, this means that sc is not linked, |
| 391 | * and caller should reset gre_family and free(sc->gre_hdr). |
| 392 | */ |
| 393 | if (sc->gre_options & GRE_UDPENCAP) { |
| 394 | error = in6_gre_setup_socket(sc); |
| 395 | if (error != 0) |
| 396 | return (error); |
| 397 | } else |
| 398 | CK_LIST_INSERT_HEAD(&GRE_HASH_SC(sc), sc, chain); |
| 399 | CK_LIST_INSERT_HEAD(&GRE_SRCHASH(&sc->gre_oip6.ip6_src), sc, srchash); |
| 400 | |
| 401 | /* Set IFF_DRV_RUNNING if interface is ready */ |
| 402 | in6_gre_set_running(sc); |
| 403 | return (0); |
| 404 | } |
| 405 | |
| 406 | int |
| 407 | in6_gre_setopts(struct gre_softc *sc, u_long cmd, uint32_t value) |
no test coverage detected