tnet.c (45916cd2) tnet.c (c793af95)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 1447 unchanged lines hidden (view full) ---

1456 boolean_t off_link;
1457 tsol_tpc_t *dst_rhtp, *gw_rhtp;
1458 tsol_ip_label_t label_type;
1459 uchar_t *opt_ptr = NULL;
1460 ts_label_t *tsl;
1461 uint8_t proto;
1462 int af, adjust;
1463 uint16_t iplen;
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 1447 unchanged lines hidden (view full) ---

1456 boolean_t off_link;
1457 tsol_tpc_t *dst_rhtp, *gw_rhtp;
1458 tsol_ip_label_t label_type;
1459 uchar_t *opt_ptr = NULL;
1460 ts_label_t *tsl;
1461 uint8_t proto;
1462 int af, adjust;
1463 uint16_t iplen;
1464 boolean_t need_tpc_rele = B_FALSE;
1465 ipaddr_t *gw;
1464
1465 ASSERT(ire != NULL && mp != NULL);
1466 ASSERT(ire->ire_stq != NULL);
1467
1468 af = (ire->ire_ipversion == IPV4_VERSION) ? AF_INET : AF_INET6;
1469
1470 if (IPH_HDR_VERSION(mp->b_rptr) == IPV4_VERSION) {
1471 ASSERT(ire->ire_ipversion == IPV4_VERSION);
1472 ipha = (ipha_t *)mp->b_rptr;
1473 psrc = &ipha->ipha_src;
1474 pdst = &ipha->ipha_dst;
1475 proto = ipha->ipha_protocol;
1476
1466
1467 ASSERT(ire != NULL && mp != NULL);
1468 ASSERT(ire->ire_stq != NULL);
1469
1470 af = (ire->ire_ipversion == IPV4_VERSION) ? AF_INET : AF_INET6;
1471
1472 if (IPH_HDR_VERSION(mp->b_rptr) == IPV4_VERSION) {
1473 ASSERT(ire->ire_ipversion == IPV4_VERSION);
1474 ipha = (ipha_t *)mp->b_rptr;
1475 psrc = &ipha->ipha_src;
1476 pdst = &ipha->ipha_dst;
1477 proto = ipha->ipha_protocol;
1478
1477 /* destination not directly reachable? */
1478 off_link = (ire->ire_gateway_addr != INADDR_ANY);
1479 /*
1480 * off_link is TRUE if destination not directly reachable.
1481 * Surya note: we avoid creation of per-dst IRE_CACHE entries
1482 * for forwarded packets, so we set off_link to be TRUE
1483 * if the packet dst is different from the ire_addr of
1484 * the ire for the nexthop.
1485 */
1486 off_link = ((ipha->ipha_dst != ire->ire_addr) ||
1487 (ire->ire_gateway_addr != INADDR_ANY));
1479 } else {
1480 ASSERT(ire->ire_ipversion == IPV6_VERSION);
1481 ip6h = (ip6_t *)mp->b_rptr;
1482 psrc = &ip6h->ip6_src;
1483 pdst = &ip6h->ip6_dst;
1484 proto = ip6h->ip6_nxt;
1485
1486 if (proto != IPPROTO_TCP && proto != IPPROTO_UDP &&

--- 31 unchanged lines hidden (view full) ---

1518 mblk_t *, mp, void *, pdst);
1519 return (NULL);
1520 }
1521
1522 /*
1523 * Gateway template must have existed for off-link destinations,
1524 * since tsol_ire_match_gwattr has ensured such condition.
1525 */
1488 } else {
1489 ASSERT(ire->ire_ipversion == IPV6_VERSION);
1490 ip6h = (ip6_t *)mp->b_rptr;
1491 psrc = &ip6h->ip6_src;
1492 pdst = &ip6h->ip6_dst;
1493 proto = ip6h->ip6_nxt;
1494
1495 if (proto != IPPROTO_TCP && proto != IPPROTO_UDP &&

--- 31 unchanged lines hidden (view full) ---

1527 mblk_t *, mp, void *, pdst);
1528 return (NULL);
1529 }
1530
1531 /*
1532 * Gateway template must have existed for off-link destinations,
1533 * since tsol_ire_match_gwattr has ensured such condition.
1534 */
1526 if (((attrp = ire->ire_gw_secattr) == NULL || attrp->igsa_rhc == NULL ||
1535 if (ire->ire_ipversion == IPV4_VERSION && off_link) {
1536 /*
1537 * Surya note: first check if we can get the gw_rhtp from
1538 * the ire_gw_secattr->igsa_rhc; if this is null, then
1539 * do a lookup based on the ire_addr (address of gw)
1540 */
1541 if (ire->ire_gw_secattr != NULL &&
1542 ire->ire_gw_secattr->igsa_rhc != NULL) {
1543 attrp = ire->ire_gw_secattr;
1544 gw_rhtp = attrp->igsa_rhc->rhc_tpc;
1545 } else {
1546 /*
1547 * use the ire_addr if this is the IRE_CACHE of nexthop
1548 */
1549 gw = (ire->ire_gateway_addr == NULL? &ire->ire_addr :
1550 &ire->ire_gateway_addr);
1551 gw_rhtp = find_tpc(gw, ire->ire_ipversion, B_FALSE);
1552 need_tpc_rele = B_TRUE;
1553 }
1554 if (gw_rhtp == NULL) {
1555 DTRACE_PROBE3(tx__ip__log__drop__forward__nogw, char *,
1556 "mp(1) dropped, no gateway in ire attributes(2)",
1557 mblk_t *, mp, tsol_ire_gw_secattr_t *, attrp);
1558 mp = NULL;
1559 goto keep_label;
1560 }
1561 }
1562 if (ire->ire_ipversion == IPV6_VERSION &&
1563 ((attrp = ire->ire_gw_secattr) == NULL || attrp->igsa_rhc == NULL ||
1527 (gw_rhtp = attrp->igsa_rhc->rhc_tpc) == NULL) && off_link) {
1528 DTRACE_PROBE3(tx__ip__log__drop__forward__nogw, char *,
1529 "mp(1) dropped, no gateway in ire attributes(2)",
1530 mblk_t *, mp, tsol_ire_gw_secattr_t *, attrp);
1531 mp = NULL;
1532 goto keep_label;
1533 }
1534

--- 109 unchanged lines hidden (view full) ---

1644
1645 DTRACE_PROBE3(tx__ip__log__info__forward__adjust, char *,
1646 "mp(1) adjusted(2) for CIPSO option removal",
1647 mblk_t *, mp, int, adjust);
1648 }
1649
1650keep_label:
1651 TPC_RELE(dst_rhtp);
1564 (gw_rhtp = attrp->igsa_rhc->rhc_tpc) == NULL) && off_link) {
1565 DTRACE_PROBE3(tx__ip__log__drop__forward__nogw, char *,
1566 "mp(1) dropped, no gateway in ire attributes(2)",
1567 mblk_t *, mp, tsol_ire_gw_secattr_t *, attrp);
1568 mp = NULL;
1569 goto keep_label;
1570 }
1571

--- 109 unchanged lines hidden (view full) ---

1681
1682 DTRACE_PROBE3(tx__ip__log__info__forward__adjust, char *,
1683 "mp(1) adjusted(2) for CIPSO option removal",
1684 mblk_t *, mp, int, adjust);
1685 }
1686
1687keep_label:
1688 TPC_RELE(dst_rhtp);
1689 if (need_tpc_rele && gw_rhtp != NULL)
1690 TPC_RELE(gw_rhtp);
1652 return (mp);
1653}
1654
1655/*
1656 * Name: tsol_rtsa_init()
1657 *
1658 * Normal: Sanity checks on the route security attributes provided by
1659 * user. Convert it into a route security parameter list to

--- 366 unchanged lines hidden ---
1691 return (mp);
1692}
1693
1694/*
1695 * Name: tsol_rtsa_init()
1696 *
1697 * Normal: Sanity checks on the route security attributes provided by
1698 * user. Convert it into a route security parameter list to

--- 366 unchanged lines hidden ---