Lines Matching defs:iptun
27 * iptun - IP Tunneling Driver
81 #include <inet/iptun.h>
117 * Table containing per-iptun-type information.
185 iptun_t *iptun = arg;
190 *val = iptun->iptun_ierrors;
193 *val = iptun->iptun_oerrors;
196 *val = iptun->iptun_rbytes;
199 *val = iptun->iptun_ipackets;
202 *val = iptun->iptun_obytes;
205 *val = iptun->iptun_opackets;
208 *val = iptun->iptun_norcvbuf;
211 *val = iptun->iptun_noxmtbuf;
223 iptun_t *iptun = arg;
226 if ((err = iptun_enter(iptun)) == 0) {
227 iptun->iptun_flags |= IPTUN_MAC_STARTED;
228 iptun_task_dispatch(iptun, IPTUN_TASK_LINK_UPDATE);
229 iptun_exit(iptun);
237 iptun_t *iptun = arg;
239 if (iptun_enter(iptun) == 0) {
240 iptun->iptun_flags &= ~IPTUN_MAC_STARTED;
241 iptun_task_dispatch(iptun, IPTUN_TASK_LINK_UPDATE);
242 iptun_exit(iptun);
272 iptun_t *iptun = arg;
278 if ((err = iptun_enter(iptun)) == 0) {
279 switch (iptun->iptun_typeinfo->iti_ipvers) {
293 err = iptun_setladdr(iptun, &ss);
294 iptun_exit(iptun);
303 iptun_t *iptun = arg;
305 if (!IS_IPTUN_RUNNING(iptun)) {
306 iptun_drop_pkt(mpchain, &iptun->iptun_noxmtbuf);
313 iptun_output(iptun, mp);
324 iptun_t *iptun = barg;
332 if ((err = iptun_enter(iptun)) != 0)
341 if (value != iptun->iptun_hoplimit) {
342 iptun->iptun_hoplimit = (uint8_t)value;
343 iptun_headergen(iptun, B_TRUE);
347 if (iptun->iptun_typeinfo->iti_type != IPTUN_TYPE_IPV6 ||
352 if (value != iptun->iptun_encaplimit) {
353 iptun->iptun_encaplimit = (uint8_t)value;
354 iptun_headergen(iptun, B_TRUE);
358 uint32_t maxmtu = iptun_get_maxmtu(iptun, NULL, 0);
360 if (value < iptun->iptun_typeinfo->iti_minmtu ||
365 iptun->iptun_flags |= IPTUN_FIXED_MTU;
366 if (value != iptun->iptun_mtu) {
367 iptun->iptun_mtu = value;
368 iptun_task_dispatch(iptun, IPTUN_TASK_MTU_UPDATE);
375 iptun_exit(iptun);
384 iptun_t *iptun = barg;
387 if ((err = iptun_enter(iptun)) != 0)
393 *(uint32_t *)pr_val = iptun->iptun_hoplimit;
397 *(uint32_t *)pr_val = iptun->iptun_encaplimit;
403 iptun_exit(iptun);
412 iptun_t *iptun = barg;
422 if (iptun->iptun_typeinfo->iti_type != IPTUN_TYPE_IPV6)
430 iptun->iptun_typeinfo->iti_minmtu,
431 iptun_get_maxmtu(iptun, NULL, 0));
448 iptun_enter(iptun_t *iptun)
450 mutex_enter(&iptun->iptun_lock);
451 while (iptun->iptun_flags & IPTUN_DELETE_PENDING)
452 cv_wait(&iptun->iptun_enter_cv, &iptun->iptun_lock);
453 if (iptun->iptun_flags & IPTUN_CONDEMNED) {
454 mutex_exit(&iptun->iptun_lock);
464 iptun_exit(iptun_t *iptun)
466 mutex_exit(&iptun->iptun_lock);
473 iptun_enter_by_linkid(datalink_id_t linkid, iptun_t **iptun)
479 (mod_hash_val_t *)iptun) == 0)
480 err = iptun_enter(*iptun);
484 *iptun = NULL;
497 * while iptun callbacks (such as iptun_m_setprop()) called from the mac
512 * iptun_delete(). We can thus still safely use iptun->iptun_mh after having
521 iptun_t *iptun;
535 if (iptun_enter_by_linkid(linkid, &iptun) != 0)
538 iptun->iptun_flags |= IPTUN_UPCALL_PENDING;
542 mtu = iptun->iptun_mtu;
545 addr = iptun->iptun_laddr;
548 addr = iptun->iptun_raddr;
551 linkstate = IS_IPTUN_RUNNING(iptun) ?
555 header_size = iptun->iptun_header_size;
556 header = iptun->iptun_header;
562 iptun_exit(iptun);
566 (void) mac_maxsdu_update(iptun->iptun_mh, mtu);
569 mac_unicst_update(iptun->iptun_mh, (uint8_t *)&addr.ia_addr);
572 mac_dst_update(iptun->iptun_mh, (uint8_t *)&addr.ia_addr);
575 mac_link_update(iptun->iptun_mh, linkstate);
578 if (mac_pdata_update(iptun->iptun_mh,
580 atomic_inc_64(&iptun->iptun_taskq_fail);
584 mutex_enter(&iptun->iptun_lock);
585 iptun->iptun_flags &= ~IPTUN_UPCALL_PENDING;
586 cv_signal(&iptun->iptun_upcall_cv);
587 mutex_exit(&iptun->iptun_lock);
591 iptun_task_dispatch(iptun_t *iptun, iptun_task_t iptun_task)
597 atomic_inc_64(&iptun->iptun_taskq_fail);
601 itd->itd_linkid = iptun->iptun_linkid;
603 atomic_inc_64(&iptun->iptun_taskq_fail);
674 iptun_setladdr(iptun_t *iptun, const struct sockaddr_storage *laddr)
676 return (iptun_setaddr(iptun->iptun_typeinfo->iti_type,
677 &iptun->iptun_laddr, laddr));
681 iptun_setraddr(iptun_t *iptun, const struct sockaddr_storage *raddr)
683 if (!(iptun->iptun_typeinfo->iti_hasraddr))
685 return (iptun_setaddr(iptun->iptun_typeinfo->iti_type,
686 &iptun->iptun_raddr, raddr));
690 iptun_canbind(iptun_t *iptun)
696 return ((iptun->iptun_flags & IPTUN_LADDR) &&
697 ((iptun->iptun_flags & IPTUN_RADDR) ||
698 !(iptun->iptun_typeinfo->iti_hasraddr)));
705 iptun_bind(iptun_t *iptun)
707 conn_t *connp = iptun->iptun_connp;
726 ASSERT(iptun_canbind(iptun));
734 connp->conn_ipversion = iptun->iptun_typeinfo->iti_ipvers;
736 switch (iptun->iptun_typeinfo->iti_type) {
738 IN6_IPADDR_TO_V4MAPPED(iptun->iptun_laddr4,
740 IN6_IPADDR_TO_V4MAPPED(iptun->iptun_raddr4,
743 if (ip_laddr_verify_v4(iptun->iptun_laddr4, IPCL_ZONEID(connp),
751 connp->conn_laddr_v6 = iptun->iptun_laddr6;
752 connp->conn_faddr_v6 = iptun->iptun_raddr6;
755 if (ip_laddr_verify_v6(&iptun->iptun_laddr6, IPCL_ZONEID(connp),
763 IN6_IPADDR_TO_V4MAPPED(iptun->iptun_laddr4,
769 switch (ip_laddr_verify_v4(iptun->iptun_laddr4,
829 iptun->iptun_flags |= IPTUN_BOUND;
841 (void) iptun_update_mtu(iptun, ixa, 0);
843 if (IS_IPTUN_RUNNING(iptun))
844 iptun_task_dispatch(iptun, IPTUN_TASK_LINK_UPDATE);
852 iptun_unbind(iptun_t *iptun)
854 ASSERT(iptun->iptun_flags & IPTUN_BOUND);
855 ASSERT(mutex_owned(&iptun->iptun_lock) ||
856 (iptun->iptun_flags & IPTUN_CONDEMNED));
857 ip_unbind(iptun->iptun_connp);
858 iptun->iptun_flags &= ~IPTUN_BOUND;
859 if (!(iptun->iptun_flags & IPTUN_CONDEMNED))
860 iptun_task_dispatch(iptun, IPTUN_TASK_LINK_UPDATE);
868 iptun_headergen(iptun_t *iptun, boolean_t update_mac)
870 switch (iptun->iptun_typeinfo->iti_ipvers) {
876 if (iptun->iptun_hoplimit == IPTUN_DEFAULT_HOPLIMIT) {
877 iptun->iptun_header_size = 0;
880 iptun->iptun_header_size = sizeof (ipha_t);
881 iptun->iptun_header4.ipha_version_and_hdr_length =
883 iptun->iptun_header4.ipha_fragment_offset_and_flags =
885 iptun->iptun_header4.ipha_ttl = iptun->iptun_hoplimit;
888 ip6_t *ip6hp = &iptun->iptun_header6.it6h_ip6h;
896 if (iptun->iptun_hoplimit == IPTUN_DEFAULT_HOPLIMIT &&
897 iptun->iptun_encaplimit == 0) {
898 iptun->iptun_header_size = 0;
903 if (iptun->iptun_encaplimit == 0) {
904 iptun->iptun_header_size = sizeof (ip6_t);
909 iptun->iptun_header_size = sizeof (iptun_ipv6hdrs_t);
919 iel = &iptun->iptun_header6.it6h_encaplim;
922 iptun->iptun_encaplimit;
925 ip6hp->ip6_hlim = iptun->iptun_hoplimit;
931 iptun_task_dispatch(iptun, IPTUN_TASK_PDATA_UPDATE);
958 iptun_set_sec_simple(iptun_t *iptun, const ipsec_req_t *ipsr)
967 netstack_t *ns = iptun->iptun_ns;
980 ASSERT(mutex_owned(&iptun->iptun_lock));
981 itp = iptun->iptun_itp;
985 if ((rc = dls_mgmt_get_linkinfo(iptun->iptun_linkid, name, NULL,
991 iptun->iptun_itp = itp;
1046 (void) iptun_update_mtu(iptun, NULL, 0);
1089 * Set the parameters included in ik on the tunnel iptun. Parameters that can
1093 iptun_setparams(iptun_t *iptun, const iptun_kparams_t *ik)
1096 netstack_t *ns = iptun->iptun_ns;
1098 uint_t orig_flags = iptun->iptun_flags;
1102 orig_laddr = iptun->iptun_laddr;
1103 if ((err = iptun_setladdr(iptun, &ik->iptun_kparam_laddr)) != 0)
1105 iptun->iptun_flags |= IPTUN_LADDR;
1110 orig_raddr = iptun->iptun_raddr;
1111 if ((err = iptun_setraddr(iptun, &ik->iptun_kparam_raddr)) != 0)
1113 iptun->iptun_flags |= IPTUN_RADDR;
1125 if (iptun->iptun_typeinfo->iti_type == IPTUN_TYPE_6TO4) {
1157 err = iptun_set_sec_simple(iptun, &ik->iptun_kparam_secinfo);
1159 iptun->iptun_flags |= IPTUN_SIMPLE_POLICY;
1160 iptun->iptun_simple_policy = ik->iptun_kparam_secinfo;
1168 iptun->iptun_laddr = orig_laddr;
1171 iptun->iptun_raddr = orig_raddr;
1172 iptun->iptun_flags = orig_flags;
1178 iptun_register(iptun_t *iptun)
1183 ASSERT(!(iptun->iptun_flags & IPTUN_MAC_REGISTERED));
1188 mac->m_type_ident = iptun->iptun_typeinfo->iti_ident;
1189 mac->m_driver = iptun;
1192 mac->m_src_addr = (uint8_t *)&iptun->iptun_laddr.ia_addr;
1193 mac->m_dst_addr = iptun->iptun_typeinfo->iti_hasraddr ?
1194 (uint8_t *)&iptun->iptun_raddr.ia_addr : NULL;
1196 mac->m_min_sdu = iptun->iptun_typeinfo->iti_minmtu;
1197 mac->m_max_sdu = iptun->iptun_mtu;
1198 if (iptun->iptun_header_size != 0) {
1199 mac->m_pdata = &iptun->iptun_header;
1200 mac->m_pdata_size = iptun->iptun_header_size;
1202 if ((err = mac_register(mac, &iptun->iptun_mh)) == 0)
1203 iptun->iptun_flags |= IPTUN_MAC_REGISTERED;
1209 iptun_unregister(iptun_t *iptun)
1213 ASSERT(iptun->iptun_flags & IPTUN_MAC_REGISTERED);
1214 if ((err = mac_unregister(iptun->iptun_mh)) == 0)
1215 iptun->iptun_flags &= ~IPTUN_MAC_REGISTERED;
1220 iptun_conn_create(iptun_t *iptun, netstack_t *ns, cred_t *credp)
1228 connp->conn_iptun = iptun;
1238 connp->conn_ixa->ixa_notify_cookie = iptun;
1274 switch (iptun->iptun_typeinfo->iti_ipvers) {
1300 iptun_t *iptun;
1302 if ((iptun = kmem_cache_alloc(iptun_cache, KM_NOSLEEP)) != NULL) {
1303 bzero(iptun, sizeof (*iptun));
1306 return (iptun);
1310 iptun_free(iptun_t *iptun)
1312 ASSERT(iptun->iptun_flags & IPTUN_CONDEMNED);
1314 if (iptun->iptun_flags & IPTUN_HASH_INSERTED) {
1315 iptun_stack_t *iptuns = iptun->iptun_iptuns;
1319 IPTUN_HASH_KEY(iptun->iptun_linkid),
1320 (mod_hash_val_t *)&iptun) == 0);
1322 iptun->iptun_flags &= ~IPTUN_HASH_INSERTED;
1324 list_remove(&iptuns->iptuns_iptunlist, iptun);
1328 if (iptun->iptun_flags & IPTUN_BOUND)
1329 iptun_unbind(iptun);
1335 if (iptun->iptun_flags & IPTUN_MAC_REGISTERED)
1336 VERIFY(iptun_unregister(iptun) == 0);
1338 if (iptun->iptun_itp != NULL) {
1343 itp_unlink(iptun->iptun_itp, iptun->iptun_ns);
1344 ITP_REFRELE(iptun->iptun_itp, iptun->iptun_ns);
1345 iptun->iptun_itp = NULL;
1346 iptun->iptun_flags &= ~IPTUN_SIMPLE_POLICY;
1354 if (iptun->iptun_connp != NULL) {
1355 iptun_conn_destroy(iptun->iptun_connp);
1356 iptun->iptun_connp = NULL;
1359 netstack_rele(iptun->iptun_ns);
1360 kmem_cache_free(iptun_cache, iptun);
1367 iptun_t *iptun = NULL;
1396 if (iptun_enter_by_linkid(ik->iptun_kparam_linkid, &iptun) == 0) {
1397 iptun_exit(iptun);
1398 iptun = NULL;
1406 if ((iptun = iptun_alloc()) == NULL) {
1411 iptun->iptun_linkid = ik->iptun_kparam_linkid;
1412 iptun->iptun_zoneid = zoneid;
1413 iptun->iptun_ns = ns;
1415 iptun->iptun_typeinfo = iptun_gettypeinfo(ik->iptun_kparam_type);
1416 if (iptun->iptun_typeinfo->iti_type == IPTUN_TYPE_UNKNOWN) {
1422 iptun->iptun_flags |= IPTUN_IMPLICIT;
1424 if ((err = iptun_setparams(iptun, ik)) != 0)
1427 iptun->iptun_hoplimit = IPTUN_DEFAULT_HOPLIMIT;
1428 if (iptun->iptun_typeinfo->iti_type == IPTUN_TYPE_IPV6)
1429 iptun->iptun_encaplimit = IPTUN_DEFAULT_ENCAPLIMIT;
1431 iptun_headergen(iptun, B_FALSE);
1433 iptun->iptun_connp = iptun_conn_create(iptun, ns, credp);
1434 if (iptun->iptun_connp == NULL) {
1439 iptun->iptun_mtu = iptun->iptun_typeinfo->iti_maxmtu;
1440 iptun->iptun_dpmtu = iptun->iptun_mtu;
1449 if ((err = dls_mgmt_get_linkinfo(iptun->iptun_linkid, linkname, NULL,
1453 iptun->iptun_itp = itp;
1461 if (iptun_canbind(iptun) && ((err = iptun_bind(iptun)) != 0))
1464 if ((err = iptun_register(iptun)) != 0)
1467 err = dls_devnet_create(iptun->iptun_mh, iptun->iptun_linkid,
1468 iptun->iptun_zoneid);
1474 * We hash by link-id as that is the key used by all other iptun
1478 IPTUN_HASH_KEY(iptun->iptun_linkid), (mod_hash_val_t)iptun)) == 0) {
1480 list_insert_head(&iptuns->iptuns_iptunlist, iptun);
1482 iptun->iptun_flags |= IPTUN_HASH_INSERTED;
1492 if (iptun == NULL && ns != NULL)
1494 if (err != 0 && iptun != NULL) {
1496 (void) dls_devnet_destroy(iptun->iptun_mh, &tmpid,
1499 iptun->iptun_flags |= IPTUN_CONDEMNED;
1500 iptun_free(iptun);
1509 iptun_t *iptun = NULL;
1511 if ((err = iptun_enter_by_linkid(linkid, &iptun)) != 0)
1515 if (iptun->iptun_zoneid != crgetzoneid(credp)) {
1516 iptun_exit(iptun);
1521 * We need to exit iptun in order to issue calls up the stack such as
1522 * dls_devnet_destroy(). If we call up while still in iptun, deadlock
1524 * threads from entering this iptun after we've exited it by setting
1531 iptun->iptun_flags |= IPTUN_DELETE_PENDING;
1534 while (iptun->iptun_flags & IPTUN_UPCALL_PENDING)
1535 cv_wait(&iptun->iptun_upcall_cv, &iptun->iptun_lock);
1537 iptun_exit(iptun);
1539 if ((err = dls_devnet_destroy(iptun->iptun_mh, &linkid, B_TRUE)) == 0) {
1542 * to the iptun MAC. If there are none, then mac_disable()
1551 if ((err = mac_disable(iptun->iptun_mh)) != 0) {
1552 (void) dls_devnet_create(iptun->iptun_mh, linkid,
1553 iptun->iptun_zoneid);
1564 mutex_enter(&iptun->iptun_lock);
1565 iptun->iptun_flags &= ~IPTUN_DELETE_PENDING;
1567 iptun->iptun_flags |= IPTUN_CONDEMNED;
1568 cv_broadcast(&iptun->iptun_enter_cv);
1569 mutex_exit(&iptun->iptun_lock);
1580 iptun_free(iptun);
1588 iptun_t *iptun;
1592 if ((err = iptun_enter_by_linkid(ik->iptun_kparam_linkid, &iptun)) != 0)
1596 if (iptun->iptun_zoneid != crgetzoneid(credp)) {
1607 if ((err = iptun_setparams(iptun, ik)) != 0)
1609 iptun_headergen(iptun, B_FALSE);
1620 if (iptun->iptun_flags & IPTUN_BOUND)
1621 iptun_unbind(iptun);
1622 if (iptun_canbind(iptun) && (err = iptun_bind(iptun)) != 0) {
1624 iptun->iptun_flags &= ~IPTUN_LADDR;
1626 iptun->iptun_flags &= ~IPTUN_RADDR;
1632 iptun_task_dispatch(iptun, IPTUN_TASK_LADDR_UPDATE);
1634 iptun_task_dispatch(iptun, IPTUN_TASK_RADDR_UPDATE);
1637 iptun_exit(iptun);
1645 iptun_t *iptun;
1653 if ((err = iptun_enter_by_linkid(ik->iptun_kparam_linkid, &iptun)) != 0)
1658 ik->iptun_kparam_linkid = iptun->iptun_linkid;
1659 ik->iptun_kparam_type = iptun->iptun_typeinfo->iti_type;
1662 if (iptun->iptun_flags & IPTUN_LADDR) {
1663 iptun_getaddr(&iptun->iptun_laddr, &ik->iptun_kparam_laddr);
1666 if (iptun->iptun_flags & IPTUN_RADDR) {
1667 iptun_getaddr(&iptun->iptun_raddr, &ik->iptun_kparam_raddr);
1671 if (iptun->iptun_flags & IPTUN_IMPLICIT)
1674 if (iptun->iptun_itp != NULL) {
1675 mutex_enter(&iptun->iptun_itp->itp_lock);
1676 if (iptun->iptun_itp->itp_flags & ITPF_P_ACTIVE) {
1678 if (iptun->iptun_flags & IPTUN_SIMPLE_POLICY) {
1681 iptun->iptun_simple_policy;
1684 mutex_exit(&iptun->iptun_itp->itp_lock);
1688 iptun_exit(iptun);
1710 iptun_t *iptun;
1712 if (iptun_enter_by_linkid(linkid, &iptun) != 0)
1714 if (iptun->iptun_itp != itp) {
1715 ASSERT(iptun->iptun_itp == NULL);
1717 iptun->iptun_itp = itp;
1723 (void) iptun_update_mtu(iptun, NULL, 0);
1724 iptun_exit(iptun);
1732 iptun_get_dst_pmtu(iptun_t *iptun, ip_xmit_attr_t *ixa)
1735 conn_t *connp = iptun->iptun_connp;
1742 if (!(iptun->iptun_flags & IPTUN_RADDR))
1765 } else if (iptun->iptun_typeinfo->iti_type != IPTUN_TYPE_6TO4) {
1783 iptun_update_dst_pmtu(iptun_t *iptun, ip_xmit_attr_t *ixa)
1786 conn_t *connp = iptun->iptun_connp;
1790 if (!(iptun->iptun_flags & IPTUN_RADDR))
1817 } else if (iptun->iptun_typeinfo->iti_type != IPTUN_TYPE_6TO4) {
1830 * There is nothing that iptun can verify in addition to IP having
1848 iptun_t *iptun = (iptun_t *)arg;
1852 (void) iptun_update_mtu(iptun, ixa, narg);
1874 iptun_get_ipsec_overhead(iptun_t *iptun)
1882 ipsec_tun_pol_t *itp = iptun->iptun_itp;
1883 netstack_t *ns = iptun->iptun_ns;
1891 if ((iptun->iptun_flags & (IPTUN_LADDR|IPTUN_RADDR)) !=
1898 (iptun->iptun_typeinfo->iti_ipvers == IPV4_VERSION);
1899 switch (iptun->iptun_typeinfo->iti_ipvers) {
1901 sel.ips_local_addr_v4 = iptun->iptun_laddr4;
1902 sel.ips_remote_addr_v4 = iptun->iptun_raddr4;
1905 sel.ips_local_addr_v6 = iptun->iptun_laddr6;
1906 sel.ips_remote_addr_v6 = iptun->iptun_raddr6;
1956 iptun_get_maxmtu(iptun_t *iptun, ip_xmit_attr_t *ixa, uint32_t new_pmtu)
1967 if (iptun->iptun_flags & IPTUN_RADDR)
1968 iptun->iptun_dpmtu = new_pmtu;
1970 } else if (iptun->iptun_flags & IPTUN_RADDR) {
1971 if ((pmtu = iptun_get_dst_pmtu(iptun, ixa)) == 0) {
1976 pmtu = iptun->iptun_dpmtu;
1978 iptun->iptun_dpmtu = pmtu;
1985 pmtu = iptun->iptun_typeinfo->iti_maxmtu;
1992 if (iptun->iptun_header_size != 0) {
1993 header_size = iptun->iptun_header_size;
1995 switch (iptun->iptun_typeinfo->iti_ipvers) {
2007 ipsec_overhead = iptun_get_ipsec_overhead(iptun);
2010 return (max(maxmtu, iptun->iptun_typeinfo->iti_minmtu));
2024 iptun_update_mtu(iptun_t *iptun, ip_xmit_attr_t *ixa, uint32_t new_pmtu)
2029 iptun_update_dst_pmtu(iptun, ixa);
2035 if (iptun->iptun_flags & IPTUN_FIXED_MTU)
2036 return (iptun->iptun_mtu);
2039 newmtu = iptun_get_maxmtu(iptun, ixa, new_pmtu);
2045 if ((iptun->iptun_flags & IPTUN_RADDR) && newmtu != iptun->iptun_mtu) {
2046 iptun->iptun_mtu = newmtu;
2047 if (iptun->iptun_flags & IPTUN_MAC_REGISTERED)
2048 iptun_task_dispatch(iptun, IPTUN_TASK_MTU_UPDATE);
2093 iptun_sendicmp_v4(iptun_t *iptun, icmph_t *icmp, ipha_t *orig_ipha, mblk_t *mp,
2101 conn_t *connp = iptun->iptun_connp;
2106 iptun_drop_pkt(mp, &iptun->iptun_noxmtbuf);
2150 iptun_sendicmp_v6(iptun_t *iptun, icmp6_t *icmp6, ip6_t *orig_ip6h, mblk_t *mp,
2158 conn_t *connp = iptun->iptun_connp;
2163 iptun_drop_pkt(mp, &iptun->iptun_noxmtbuf);
2203 iptun_icmp_error_v4(iptun_t *iptun, ipha_t *orig_ipha, mblk_t *mp,
2212 iptun_sendicmp_v4(iptun, &icmp, orig_ipha, mp, tsl);
2216 iptun_icmp_fragneeded_v4(iptun_t *iptun, uint32_t newmtu, ipha_t *orig_ipha,
2226 iptun_sendicmp_v4(iptun, &icmp, orig_ipha, mp, tsl);
2230 iptun_icmp_error_v6(iptun_t *iptun, ip6_t *orig_ip6h, mblk_t *mp,
2241 iptun_sendicmp_v6(iptun, &icmp6, orig_ip6h, mp, tsl);
2245 iptun_icmp_toobig_v6(iptun_t *iptun, uint32_t newmtu, ip6_t *orig_ip6h,
2254 iptun_sendicmp_v6(iptun, &icmp6, orig_ip6h, mp, tsl);
2387 iptun_input_icmp_v4(iptun_t *iptun, mblk_t *data_mp, icmph_t *icmph,
2414 iptun_drop_pkt(data_mp, &iptun->iptun_ierrors);
2422 data_mp = ipsec_tun_inbound(ira, data_mp, iptun->iptun_itp,
2423 inner4, inner6, outer4, outer6, -outer_hlen, iptun->iptun_ns);
2426 atomic_inc_64(&iptun->iptun_ierrors);
2440 iptun_drop_pkt(data_mp, &iptun->iptun_norcvbuf);
2456 newmtu = iptun_update_mtu(iptun, NULL,
2460 iptun_icmp_fragneeded_v4(iptun, newmtu, inner4,
2463 iptun_icmp_toobig_v6(iptun, newmtu, inner6,
2490 iptun_drop_pkt(data_mp, &iptun->iptun_oerrors);
2493 iptun_drop_pkt(data_mp, &iptun->iptun_norcvbuf);
2498 iptun_icmp_error_v4(iptun, inner4, data_mp, type, code,
2501 iptun_icmp_error_v6(iptun, inner6, data_mp, type, code, 0,
2560 iptun_input_icmp_v6(iptun_t *iptun, mblk_t *data_mp, icmp6_t *icmp6h,
2588 iptun_drop_pkt(data_mp, &iptun->iptun_ierrors);
2592 data_mp = ipsec_tun_inbound(ira, data_mp, iptun->iptun_itp,
2593 inner4, inner6, outer4, outer6, -outer_hlen, iptun->iptun_ns);
2596 atomic_inc_64(&iptun->iptun_ierrors);
2610 iptun_drop_pkt(data_mp, &iptun->iptun_norcvbuf);
2629 iptun_drop_pkt(data_mp, &iptun->iptun_oerrors);
2649 newmtu = iptun_update_mtu(iptun, NULL,
2653 iptun_icmp_fragneeded_v4(iptun, newmtu, inner4,
2656 iptun_icmp_toobig_v6(iptun, newmtu, inner6, data_mp,
2662 iptun_drop_pkt(data_mp, &iptun->iptun_norcvbuf);
2667 iptun_icmp_error_v4(iptun, inner4, data_mp, type, code,
2670 iptun_icmp_error_v6(iptun, inner6, data_mp, type, code, 0,
2683 iptun_t *iptun = connp->conn_iptun;
2697 iptun_drop_pkt(mp, &iptun->iptun_norcvbuf);
2705 switch (iptun->iptun_typeinfo->iti_ipvers) {
2711 iptun_input_icmp_v4(iptun, mp, (icmph_t *)(mp->b_rptr + hlen),
2715 iptun_input_icmp_v6(iptun, mp, (icmp6_t *)(mp->b_rptr + hlen),
2722 iptun_in_6to4_ok(iptun_t *iptun, ipha_t *outer4, ip6_t *inner6)
2758 if (iptun->iptun_iptuns->iptuns_relay_rtr_addr == INADDR_ANY)
2776 iptun_t *iptun = connp->conn_iptun;
2806 data_mp = ipsec_tun_inbound(ira, data_mp, iptun->iptun_itp,
2807 inner4, inner6, outer4, outer6, outer_hlen, iptun->iptun_ns);
2813 if (iptun->iptun_typeinfo->iti_type == IPTUN_TYPE_6TO4 &&
2814 !iptun_in_6to4_ok(iptun, outer4, inner6))
2827 atomic_inc_64(&iptun->iptun_ipackets);
2828 atomic_add_64(&iptun->iptun_rbytes, msgdsize(data_mp));
2829 mac_rx(iptun->iptun_mh, NULL, data_mp);
2835 iptun_drop_pkt(data_mp, &iptun->iptun_ierrors);
2844 iptun_out_process_6to4(iptun_t *iptun, ipha_t *outer4, ip6_t *inner6)
2905 if (iptun->iptun_iptuns->iptuns_relay_rtr_addr == INADDR_ANY)
2907 outer4->ipha_dst = iptun->iptun_iptuns->iptuns_relay_rtr_addr;
2914 * packet infinitely bouncing between ip and iptun.
2924 iptun_out_process_ipv4(iptun_t *iptun, mblk_t *mp, ipha_t *outer4,
2929 size_t minmtu = iptun->iptun_typeinfo->iti_minmtu;
2963 (iptun->iptun_typeinfo->iti_type != IPTUN_TYPE_6TO4)) {
2980 iptun_insert_encaplimit(iptun_t *iptun, mblk_t *mp, ip6_t *outer6,
2992 iptun_drop_pkt(mp, &iptun->iptun_noxmtbuf);
3021 iptun_out_process_ipv6(iptun_t *iptun, mblk_t *mp, ip6_t *outer6,
3026 size_t minmtu = iptun->iptun_typeinfo->iti_minmtu;
3050 iptun_icmp_error_v6(iptun, inner6, mp, ICMP6_PARAM_PROB,
3052 atomic_inc_64(&iptun->iptun_noxmtbuf);
3060 if (iptun->iptun_encaplimit == 0) {
3061 if ((mp = iptun_insert_encaplimit(iptun, mp, outer6,
3105 iptun_output(iptun_t *iptun, mblk_t *mp)
3107 conn_t *connp = iptun->iptun_connp;
3116 iptun_drop_pkt(mp, &iptun->iptun_noxmtbuf);
3123 if (iptun->iptun_typeinfo->iti_type == IPTUN_TYPE_6TO4) {
3124 iptun_output_6to4(iptun, mp);
3143 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3165 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3171 iptun_output_common(iptun, ixa, mp);
3179 iptun_output_6to4(iptun_t *iptun, mblk_t *mp)
3181 conn_t *connp = iptun->iptun_connp;
3196 if (!iptun_out_process_6to4(iptun, outer4, inner6)) {
3197 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3216 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3257 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3263 iptun_output_common(iptun, ixa, mp);
3352 iptun_output_common(iptun_t *iptun, ip_xmit_attr_t *ixa, mblk_t *mp)
3354 ipsec_tun_pol_t *itp = iptun->iptun_itp;
3367 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3376 mp = iptun_out_process_ipv4(iptun, mp, outer4, inner4, inner6,
3379 mp = iptun_out_process_ipv6(iptun, mp, outer6, inner4, inner6,
3390 mp = ipsec_tun_outbound(mp, iptun, inner4, inner6, outer4,
3393 atomic_inc_64(&iptun->iptun_oerrors);
3405 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3424 size_t minmtu = iptun->iptun_typeinfo->iti_minmtu;
3426 atomic_inc_64(&iptun->iptun_opackets);
3427 atomic_add_64(&iptun->iptun_obytes, ixa->ixa_pktlen);
3446 atomic_inc_64(&iptun->iptun_opackets);
3447 atomic_add_64(&iptun->iptun_obytes, ixa->ixa_pktlen);
3456 (void) iptun_update_mtu(iptun, ixa, 0);
3468 atomic_inc_64(&iptun->iptun_oerrors);
3480 iptun_drop_pkt(mp, &iptun->iptun_oerrors);
3485 atomic_inc_64(&iptun->iptun_opackets);
3486 atomic_add_64(&iptun->iptun_obytes, ixa->ixa_pktlen);
3491 (void) iptun_update_mtu(iptun, ixa, 0);