Lines Matching refs:pr
40 static void prefix_print(struct prefix *pr);
41 static void prefix_insert(struct phyint *pi, struct prefix *pr);
574 struct prefix *pr;
621 for (pr = pi->pi_prefix_list; pr != NULL; pr = pr->pr_next)
622 prefix_print(pr);
828 struct prefix *pr;
830 for (pr = pi->pi_prefix_list; pr != NULL; pr = pr->pr_next) {
831 if (!(pr->pr_flags & IFF_TEMPORARY) ||
832 (pr->pr_flags & IFF_DEPRECATED) ||
833 (!token_equal(pr->pr_address, pi->pi_tmp_token,
837 pr->pr_PreferredLifetime = 0;
838 pr->pr_state |= PR_DEPRECATED;
839 prefix_update_k(pr);
856 struct prefix *pr, *newpr;
883 for (pr = pi->pi_prefix_list; pr != NULL; pr = pr->pr_next) {
885 if (!(pr->pr_state & PR_AUTO) || pr->pr_state & PR_STATIC ||
886 pr->pr_state & PR_DEPRECATED ||
887 pr->pr_flags & IFF_TEMPORARY)
890 newpr = prefix_create(pi, pr->pr_prefix, pr->pr_prefix_len,
895 (void) inet_ntop(AF_INET6, &pr->pr_prefix, pbuf,
916 opt.nd_opt_pi_prefix_len = pr->pr_prefix_len;
919 htonl(pr->pr_ValidLifetime / 1000);
921 htonl(pr->pr_PreferredLifetime / 1000);
922 if (pr->pr_state & PR_ONLINK)
924 opt.nd_opt_pi_prefix = pr->pr_prefix;
932 (void) inet_ntop(AF_INET6, &pr->pr_prefix, pbuf,
941 if (pr->pr_state & PR_ONLINK) {
994 struct prefix *pr;
1003 for (pr = pi->pi_prefix_list; pr != NULL; pr = pr->pr_next) {
1004 if (pr->pr_prefix_len == prefixlen &&
1005 prefix_equal(prefix, pr->pr_prefix, prefixlen))
1006 return (pr);
1071 struct prefix *pr;
1080 for (pr = pi->pi_prefix_list; pr != NULL; pr = pr->pr_next) {
1081 if (strcmp(name, pr->pr_name) == 0)
1082 return (pr);
1093 prefix_lookup_addr_match(struct prefix *pr)
1103 inet_ntop(AF_INET6, (void *)&pr->pr_address,
1104 abuf, sizeof (abuf)), pr->pr_prefix_len);
1106 prefix = pr->pr_prefix;
1107 prefixlen = pr->pr_prefix_len;
1110 if (otherpr == pr)
1113 IN6_ARE_ADDR_EQUAL(&pr->pr_address,
1127 struct prefix *pr;
1135 pr = (struct prefix *)calloc(sizeof (struct prefix), 1);
1136 if (pr == NULL) {
1144 prefix_set(&pr->pr_prefix, prefix, prefixlen);
1145 pr->pr_prefix_len = prefixlen;
1146 pr->pr_PreferredLifetime = PREFIX_INFINITY;
1147 pr->pr_ValidLifetime = PREFIX_INFINITY;
1148 pr->pr_OnLinkLifetime = PREFIX_INFINITY;
1149 pr->pr_kernel_state = 0;
1150 pr->pr_flags |= flags;
1151 prefix_insert(pi, pr);
1152 return (pr);
1162 struct prefix *pr;
1168 pr = (struct prefix *)calloc(sizeof (struct prefix), 1);
1169 if (pr == NULL) {
1173 (void) strncpy(pr->pr_name, name, sizeof (pr->pr_name));
1174 pr->pr_name[sizeof (pr->pr_name) - 1] = '\0';
1175 prefix_insert(pi, pr);
1176 return (pr);
1181 prefix_insert(struct phyint *pi, struct prefix *pr)
1183 pr->pr_next = pi->pi_prefix_list;
1184 pr->pr_prev = NULL;
1186 pi->pi_prefix_list->pr_prev = pr;
1187 pi->pi_prefix_list = pr;
1188 pr->pr_physical = pi;
1200 prefix_init_from_k(struct prefix *pr)
1204 int sock = pr->pr_physical->pi_sock;
1206 (void) strncpy(lifr.lifr_name, pr->pr_name, sizeof (lifr.lifr_name));
1209 logperror_pr(pr, "prefix_init_from_k: ioctl (get addr)");
1214 pr->pr_name);
1218 pr->pr_address = sin6->sin6_addr;
1221 logperror_pr(pr, "prefix_init_from_k: ioctl (get flags)");
1224 pr->pr_flags = lifr.lifr_flags;
1230 struct phyint *pi = pr->pr_physical;
1233 pr->pr_prefix_len = IPV6_ABITS;
1235 IN6_IS_ADDR_UNSPECIFIED(&pr->pr_address) ||
1236 IN6_IS_ADDR_LINKLOCAL(&pr->pr_address)) {
1240 pr->pr_name);
1254 prefix_equal(pr->pr_prefix, pr2->pr_prefix,
1256 pr->pr_prefix_len = pr2->pr_prefix_len;
1264 "resolicit\n", pr->pr_name);
1271 pr2->pr_name, pr->pr_name);
1272 prefix_update_dhcp(pr);
1279 prefix_update_ipadm_addrobj(pr, _B_TRUE);
1282 logperror_pr(pr,
1289 pr->pr_name);
1297 pr->pr_prefix_len = lifr.lifr_addrlen;
1298 prefix_set(&pr->pr_prefix, sin6->sin6_addr, pr->pr_prefix_len);
1300 if (pr->pr_prefix_len != IPV6_ABITS &&
1301 (pr->pr_flags & IFF_UP) &&
1302 IN6_ARE_ADDR_EQUAL(&pr->pr_address, &pr->pr_prefix)) {
1308 pr->pr_name,
1309 inet_ntop(AF_INET6, (void *)&pr->pr_address,
1310 abuf, sizeof (abuf)), pr->pr_prefix_len);
1314 pr->pr_kernel_state = 0;
1315 if (pr->pr_prefix_len != IPV6_ABITS)
1316 pr->pr_kernel_state |= PR_ONLINK;
1317 if (!(pr->pr_flags & (IFF_NOLOCAL | IFF_DHCPRUNNING)))
1318 pr->pr_kernel_state |= PR_AUTO;
1319 if ((pr->pr_flags & IFF_DEPRECATED) && (pr->pr_kernel_state & PR_AUTO))
1320 pr->pr_kernel_state |= PR_DEPRECATED;
1321 if (!(pr->pr_flags & IFF_ADDRCONF)) {
1323 pr->pr_kernel_state |= PR_STATIC;
1325 pr->pr_state = pr->pr_kernel_state;
1327 if (pr->pr_state & PR_AUTO) {
1328 pr->pr_prefix_len =
1329 IPV6_ABITS - pr->pr_physical->pi_token_length;
1330 prefix_set(&pr->pr_prefix, pr->pr_prefix, pr->pr_prefix_len);
1334 pr->pr_ValidLifetime = NDP_PREFIX_DEFAULT_LIFETIME;
1335 pr->pr_PreferredLifetime = NDP_PREFIX_DEFAULT_LIFETIME;
1336 pr->pr_OnLinkLifetime = NDP_PREFIX_DEFAULT_LIFETIME;
1343 if (pr->pr_flags & IFF_TEMPORARY)
1344 pr->pr_CreateTime = getcurrenttime() / MILLISEC;
1346 if (pr->pr_kernel_state == 0)
1347 pr->pr_name[0] = '\0';
1352 pr->pr_kernel_state = 0;
1353 pr->pr_name[0] = '\0';
1365 prefix_delete(struct prefix *pr)
1372 pr->pr_physical->pi_name, pr->pr_name,
1373 inet_ntop(AF_INET6, (void *)&pr->pr_prefix,
1374 abuf, sizeof (abuf)), pr->pr_prefix_len);
1376 pi = pr->pr_physical;
1379 pr->pr_state &= PR_STATIC;
1380 if (pr->pr_kernel_state != pr->pr_state)
1381 prefix_update_k(pr);
1383 if (pr->pr_prev == NULL) {
1385 pi->pi_prefix_list = pr->pr_next;
1387 pr->pr_prev->pr_next = pr->pr_next;
1389 if (pr->pr_next != NULL)
1390 pr->pr_next->pr_prev = pr->pr_prev;
1391 pr->pr_next = pr->pr_prev = NULL;
1393 free(pr);
1401 prefix_modify_flags(struct prefix *pr, uint64_t onflags, uint64_t offflags)
1404 struct phyint *pi = pr->pr_physical;
1411 pr->pr_physical->pi_name,
1412 pr->pr_name,
1413 inet_ntop(AF_INET6, (void *)&pr->pr_prefix,
1414 abuf, sizeof (abuf)), pr->pr_prefix_len,
1415 pr->pr_flags, onflags, offflags);
1418 if (!(pr->pr_state & PR_STATIC) &&
1419 strcmp(pr->pr_name, pi->pi_name) == 0) {
1426 (void) strncpy(lifr.lifr_name, pr->pr_name, sizeof (lifr.lifr_name));
1430 logperror_pr(pr, "prefix_modify_flags: SIOCGLIFFLAGS");
1432 " on 0x%llx off 0x%llx\n", pr->pr_physical->pi_name,
1433 pr->pr_name, pr->pr_flags, onflags, offflags);
1440 pr->pr_flags = lifr.lifr_flags;
1443 logperror_pr(pr, "prefix_modify_flags: SIOCSLIFFLAGS");
1446 pr->pr_physical->pi_name, pr->pr_name,
1458 prefix_update_dhcp(struct prefix *pr)
1463 (void) strlcpy(lifr.lifr_name, pr->pr_name, sizeof (lifr.lifr_name));
1466 pr->pr_address, pr->pr_prefix_len);
1467 lifr.lifr_addrlen = pr->pr_prefix_len;
1472 if (ioctl(pr->pr_physical->pi_sock, SIOCSLIFSUBNET, (char *)&lifr) ==
1474 logperror_pr(pr, "prefix_update_dhcp: ioctl (set subnet)");
1484 prefix_update_k(struct prefix *pr)
1489 struct phyint *pi = pr->pr_physical;
1494 "from %s to %s\n", pr->pr_physical->pi_name, pr->pr_name,
1495 inet_ntop(AF_INET6, (void *)&pr->pr_prefix,
1496 abuf, sizeof (abuf)), pr->pr_prefix_len,
1497 prefix_print_state(pr->pr_kernel_state, buf1,
1499 prefix_print_state(pr->pr_state, buf2, sizeof (buf2)));
1502 if (pr->pr_kernel_state == pr->pr_state)
1506 if (pr->pr_state & PR_STATIC)
1509 if (pr->pr_kernel_state == 0) {
1515 if (pr->pr_name[0] != '\0') {
1519 pr->pr_physical->pi_name, pr->pr_name,
1520 inet_ntop(AF_INET6, (void *)&pr->pr_prefix,
1521 abuf, sizeof (abuf)), pr->pr_prefix_len,
1522 prefix_print_state(pr->pr_kernel_state, buf1,
1524 prefix_print_state(pr->pr_state, buf2,
1534 logperror_pr(pr, "prefix_update_k: SIOCLIFADDIF");
1537 (void) strncpy(pr->pr_name, lifr.lifr_name,
1538 sizeof (pr->pr_name));
1539 pr->pr_name[sizeof (pr->pr_name) - 1] = '\0';
1542 pr->pr_name);
1553 if (pr->pr_flags & IFF_TEMPORARY)
1555 if (prefix_modify_flags(pr, onflags, 0) == -1)
1558 if ((pr->pr_state & (PR_ONLINK|PR_AUTO)) == 0) {
1560 if (prefix_modify_flags(pr, 0, IFF_UP|IFF_DEPRECATED) == -1)
1562 (void) strncpy(lifr.lifr_name, pr->pr_name,
1568 pr->pr_name);
1575 if (!(pr->pr_state & PR_STATIC) &&
1576 strcmp(pr->pr_name, pi->pi_name) == 0) {
1586 logperror_pr(pr, "prefix_update_k: SIOCLIFREMOVEIF");
1588 pr->pr_kernel_state = 0;
1589 pr->pr_name[0] = '\0';
1592 if ((pr->pr_state & PR_AUTO) && !(pr->pr_kernel_state & PR_AUTO)) {
1598 (void) strncpy(lifr.lifr_name, pr->pr_name,
1604 sin6->sin6_addr = pr->pr_address;
1608 pr->pr_name,
1609 inet_ntop(AF_INET6, (void *)&pr->pr_address,
1613 logperror_pr(pr, "prefix_update_k: SIOCSLIFADDR");
1620 prefix_update_ipadm_addrobj(pr, _B_TRUE);
1621 if (pr->pr_state & PR_ONLINK) {
1622 sin6->sin6_addr = pr->pr_prefix;
1623 lifr.lifr_addrlen = pr->pr_prefix_len;
1625 sin6->sin6_addr = pr->pr_address;
1630 "%s/%u for PR_AUTO on\n", pr->pr_name,
1635 logperror_pr(pr, "prefix_update_k: SIOCSLIFSUBNET");
1650 sin6->sin6_addr = pr->pr_prefix;
1658 pr->pr_name, inet_ntop(AF_INET6,
1664 logperror_pr(pr,
1669 if (prefix_modify_flags(pr, IFF_UP, IFF_NOLOCAL) == -1)
1671 pr->pr_kernel_state |= PR_AUTO;
1672 if (pr->pr_state & PR_ONLINK)
1673 pr->pr_kernel_state |= PR_ONLINK;
1675 pr->pr_kernel_state &= ~PR_ONLINK;
1677 if (!(pr->pr_state & PR_AUTO) && (pr->pr_kernel_state & PR_AUTO)) {
1679 if (prefix_modify_flags(pr, IFF_NOLOCAL, 0) == -1)
1681 (void) strncpy(lifr.lifr_name, pr->pr_name,
1689 "for PR_AUTO off\n", pr->pr_name,
1694 logperror_pr(pr, "prefix_update_k: SIOCSLIFADDR");
1697 pr->pr_kernel_state &= ~PR_AUTO;
1699 if ((pr->pr_state & PR_DEPRECATED) &&
1700 !(pr->pr_kernel_state & PR_DEPRECATED) &&
1701 (pr->pr_kernel_state & PR_AUTO)) {
1703 if (prefix_modify_flags(pr, IFF_DEPRECATED, 0) == -1)
1705 pr->pr_kernel_state |= PR_DEPRECATED;
1707 if (!(pr->pr_state & PR_DEPRECATED) &&
1708 (pr->pr_kernel_state & PR_DEPRECATED)) {
1709 if (prefix_modify_flags(pr, 0, IFF_DEPRECATED) == -1)
1711 pr->pr_kernel_state &= ~PR_DEPRECATED;
1713 if ((pr->pr_state & PR_ONLINK) && !(pr->pr_kernel_state & PR_ONLINK)) {
1715 (void) strncpy(lifr.lifr_name, pr->pr_name,
1721 sin6->sin6_addr = pr->pr_prefix;
1722 lifr.lifr_addrlen = pr->pr_prefix_len;
1725 "%s/%d for PR_ONLINK on\n", pr->pr_name,
1730 logperror_pr(pr, "prefix_update_k: SIOCSLIFSUBNET");
1739 if (!(pr->pr_state & PR_AUTO) &&
1740 prefix_modify_flags(pr, IFF_UP | IFF_NOLOCAL, 0) == -1)
1742 pr->pr_kernel_state |= PR_ONLINK;
1744 if (!(pr->pr_state & PR_ONLINK) && (pr->pr_kernel_state & PR_ONLINK)) {
1746 (void) strncpy(lifr.lifr_name, pr->pr_name,
1752 sin6->sin6_addr = pr->pr_address;
1756 "%s/%d for PR_ONLINK off\n", pr->pr_name,
1761 logperror_pr(pr, "prefix_update_k: SIOCSLIFSUBNET");
1764 pr->pr_kernel_state &= ~PR_ONLINK;
1775 prefix_timer(struct prefix *pr, uint_t elapsed)
1783 pr->pr_name,
1784 inet_ntop(AF_INET6, (void *)&pr->pr_prefix,
1785 abuf, sizeof (abuf)), pr->pr_prefix_len,
1786 elapsed, pr->pr_ValidLifetime, pr->pr_PreferredLifetime,
1787 pr->pr_OnLinkLifetime);
1791 if (pr->pr_state & PR_STATIC)
1794 if (pr->pr_AutonomousFlag &&
1795 (pr->pr_PreferredLifetime != PREFIX_INFINITY)) {
1796 if (pr->pr_PreferredLifetime <= elapsed) {
1797 pr->pr_PreferredLifetime = 0;
1799 pr->pr_PreferredLifetime -= elapsed;
1800 if (pr->pr_PreferredLifetime < next)
1801 next = pr->pr_PreferredLifetime;
1804 if (pr->pr_AutonomousFlag &&
1805 (pr->pr_ValidLifetime != PREFIX_INFINITY)) {
1806 if (pr->pr_ValidLifetime <= elapsed) {
1807 pr->pr_ValidLifetime = 0;
1809 pr->pr_ValidLifetime -= elapsed;
1810 if (pr->pr_ValidLifetime < next)
1811 next = pr->pr_ValidLifetime;
1814 if (pr->pr_OnLinkFlag &&
1815 (pr->pr_OnLinkLifetime != PREFIX_INFINITY)) {
1816 if (pr->pr_OnLinkLifetime <= elapsed) {
1817 pr->pr_OnLinkLifetime = 0;
1819 pr->pr_OnLinkLifetime -= elapsed;
1820 if (pr->pr_OnLinkLifetime < next)
1821 next = pr->pr_OnLinkLifetime;
1824 if (pr->pr_AutonomousFlag && pr->pr_ValidLifetime == 0)
1825 pr->pr_state &= ~(PR_AUTO|PR_DEPRECATED);
1826 if (pr->pr_AutonomousFlag && pr->pr_PreferredLifetime == 0 &&
1827 (pr->pr_state & PR_AUTO)) {
1828 pr->pr_state |= PR_DEPRECATED;
1831 "prefix(%s)\n", pr->pr_name);
1833 if (pr->pr_OnLinkFlag && pr->pr_OnLinkLifetime == 0)
1834 pr->pr_state &= ~PR_ONLINK;
1836 if (pr->pr_state != pr->pr_kernel_state) {
1840 if ((pr->pr_kernel_state & PR_AUTO) &&
1841 !(pr->pr_state & PR_AUTO)) {
1846 inet_ntop(AF_INET6, (void *)&pr->pr_address,
1849 prefix_update_k(pr);
1892 prefix_print(struct prefix *pr)
1898 "kernel_state %s\n", pr->pr_name,
1899 inet_ntop(AF_INET6, (void *)&pr->pr_prefix, abuf, sizeof (abuf)),
1900 pr->pr_prefix_len,
1901 prefix_print_state(pr->pr_state, buf2, sizeof (buf2)),
1902 prefix_print_state(pr->pr_kernel_state, buf1, sizeof (buf1)));
1904 inet_ntop(AF_INET6, (void *)&pr->pr_address, abuf, sizeof (abuf)),
1905 pr->pr_flags, pr->pr_in_use);
1907 "OnLinkLifetime %u\n", pr->pr_ValidLifetime,
1908 pr->pr_PreferredLifetime, pr->pr_OnLinkLifetime);
1910 pr->pr_OnLinkFlag, pr->pr_AutonomousFlag);
2350 prefix_update_ipadm_addrobj(struct prefix *pr, boolean_t add)
2352 struct phyint *pi = pr->pr_physical;
2365 pr->pr_name[0] == '\0' || IN6_IS_ADDR_LINKLOCAL(&pr->pr_address) ||
2366 (!(pr->pr_flags & IFF_ADDRCONF) &&
2367 !(pr->pr_flags & IFF_DHCPRUNNING))) {
2375 cp = strrchr(pr->pr_name, ':');