ip6_output.c (108824) | ip6_output.c (109623) |
---|---|
1/* $FreeBSD: head/sys/netinet6/ip6_output.c 108824 2003-01-06 21:29:27Z sam $ */ | 1/* $FreeBSD: head/sys/netinet6/ip6_output.c 109623 2003-01-21 08:56:16Z alfred $ */ |
2/* $KAME: ip6_output.c,v 1.279 2002/01/26 06:12:30 jinmei Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 1025 unchanged lines hidden (view full) --- 1035 1036 /* 1037 * Loop through length of segment after first fragment, 1038 * make new header and copy data of each part and link onto 1039 * chain. 1040 */ 1041 m0 = m; 1042 for (off = hlen; off < tlen; off += len) { | 2/* $KAME: ip6_output.c,v 1.279 2002/01/26 06:12:30 jinmei Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 1025 unchanged lines hidden (view full) --- 1035 1036 /* 1037 * Loop through length of segment after first fragment, 1038 * make new header and copy data of each part and link onto 1039 * chain. 1040 */ 1041 m0 = m; 1042 for (off = hlen; off < tlen; off += len) { |
1043 MGETHDR(m, M_DONTWAIT, MT_HEADER); | 1043 MGETHDR(m, M_NOWAIT, MT_HEADER); |
1044 if (!m) { 1045 error = ENOBUFS; 1046 ip6stat.ip6s_odropped++; 1047 goto sendorfree; 1048 } 1049 m->m_pkthdr.rcvif = NULL; 1050 m->m_flags = m0->m_flags & M_COPYFLAGS; 1051 *mnext = m; --- 96 unchanged lines hidden (view full) --- 1148 caddr_t hdr; 1149 int hlen; 1150{ 1151 struct mbuf *m; 1152 1153 if (hlen > MCLBYTES) 1154 return(ENOBUFS); /* XXX */ 1155 | 1044 if (!m) { 1045 error = ENOBUFS; 1046 ip6stat.ip6s_odropped++; 1047 goto sendorfree; 1048 } 1049 m->m_pkthdr.rcvif = NULL; 1050 m->m_flags = m0->m_flags & M_COPYFLAGS; 1051 *mnext = m; --- 96 unchanged lines hidden (view full) --- 1148 caddr_t hdr; 1149 int hlen; 1150{ 1151 struct mbuf *m; 1152 1153 if (hlen > MCLBYTES) 1154 return(ENOBUFS); /* XXX */ 1155 |
1156 MGET(m, M_DONTWAIT, MT_DATA); | 1156 MGET(m, M_NOWAIT, MT_DATA); |
1157 if (!m) 1158 return(ENOBUFS); 1159 1160 if (hlen > MLEN) { | 1157 if (!m) 1158 return(ENOBUFS); 1159 1160 if (hlen > MLEN) { |
1161 MCLGET(m, M_DONTWAIT); | 1161 MCLGET(m, M_NOWAIT); |
1162 if ((m->m_flags & M_EXT) == 0) { 1163 m_free(m); 1164 return(ENOBUFS); 1165 } 1166 } 1167 m->m_len = hlen; 1168 if (hdr) 1169 bcopy(hdr, mtod(m, caddr_t), hlen); --- 18 unchanged lines hidden (view full) --- 1188 1189 /* 1190 * If there is no hop-by-hop options header, allocate new one. 1191 * If there is one but it doesn't have enough space to store the 1192 * jumbo payload option, allocate a cluster to store the whole options. 1193 * Otherwise, use it to store the options. 1194 */ 1195 if (exthdrs->ip6e_hbh == 0) { | 1162 if ((m->m_flags & M_EXT) == 0) { 1163 m_free(m); 1164 return(ENOBUFS); 1165 } 1166 } 1167 m->m_len = hlen; 1168 if (hdr) 1169 bcopy(hdr, mtod(m, caddr_t), hlen); --- 18 unchanged lines hidden (view full) --- 1188 1189 /* 1190 * If there is no hop-by-hop options header, allocate new one. 1191 * If there is one but it doesn't have enough space to store the 1192 * jumbo payload option, allocate a cluster to store the whole options. 1193 * Otherwise, use it to store the options. 1194 */ 1195 if (exthdrs->ip6e_hbh == 0) { |
1196 MGET(mopt, M_DONTWAIT, MT_DATA); | 1196 MGET(mopt, M_NOWAIT, MT_DATA); |
1197 if (mopt == 0) 1198 return(ENOBUFS); 1199 mopt->m_len = JUMBOOPTLEN; 1200 optbuf = mtod(mopt, u_char *); 1201 optbuf[1] = 0; /* = ((JUMBOOPTLEN) >> 3) - 1 */ 1202 exthdrs->ip6e_hbh = mopt; 1203 } else { 1204 struct ip6_hbh *hbh; --- 15 unchanged lines hidden (view full) --- 1220 */ 1221 if (oldoptlen + JUMBOOPTLEN > MCLBYTES) 1222 return(ENOBUFS); 1223 1224 /* 1225 * As a consequence, we must always prepare a cluster 1226 * at this point. 1227 */ | 1197 if (mopt == 0) 1198 return(ENOBUFS); 1199 mopt->m_len = JUMBOOPTLEN; 1200 optbuf = mtod(mopt, u_char *); 1201 optbuf[1] = 0; /* = ((JUMBOOPTLEN) >> 3) - 1 */ 1202 exthdrs->ip6e_hbh = mopt; 1203 } else { 1204 struct ip6_hbh *hbh; --- 15 unchanged lines hidden (view full) --- 1220 */ 1221 if (oldoptlen + JUMBOOPTLEN > MCLBYTES) 1222 return(ENOBUFS); 1223 1224 /* 1225 * As a consequence, we must always prepare a cluster 1226 * at this point. 1227 */ |
1228 MGET(n, M_DONTWAIT, MT_DATA); | 1228 MGET(n, M_NOWAIT, MT_DATA); |
1229 if (n) { | 1229 if (n) { |
1230 MCLGET(n, M_DONTWAIT); | 1230 MCLGET(n, M_NOWAIT); |
1231 if ((n->m_flags & M_EXT) == 0) { 1232 m_freem(n); 1233 n = NULL; 1234 } 1235 } 1236 if (!n) 1237 return(ENOBUFS); 1238 n->m_len = oldoptlen + JUMBOOPTLEN; --- 38 unchanged lines hidden (view full) --- 1277 struct mbuf *m0, *m; 1278 int hlen; 1279 struct ip6_frag **frghdrp; 1280{ 1281 struct mbuf *n, *mlast; 1282 1283 if (hlen > sizeof(struct ip6_hdr)) { 1284 n = m_copym(m0, sizeof(struct ip6_hdr), | 1231 if ((n->m_flags & M_EXT) == 0) { 1232 m_freem(n); 1233 n = NULL; 1234 } 1235 } 1236 if (!n) 1237 return(ENOBUFS); 1238 n->m_len = oldoptlen + JUMBOOPTLEN; --- 38 unchanged lines hidden (view full) --- 1277 struct mbuf *m0, *m; 1278 int hlen; 1279 struct ip6_frag **frghdrp; 1280{ 1281 struct mbuf *n, *mlast; 1282 1283 if (hlen > sizeof(struct ip6_hdr)) { 1284 n = m_copym(m0, sizeof(struct ip6_hdr), |
1285 hlen - sizeof(struct ip6_hdr), M_DONTWAIT); | 1285 hlen - sizeof(struct ip6_hdr), M_NOWAIT); |
1286 if (n == 0) 1287 return(ENOBUFS); 1288 m->m_next = n; 1289 } else 1290 n = m; 1291 1292 /* Search for the last mbuf of unfragmentable part. */ 1293 for (mlast = n; mlast->m_next; mlast = mlast->m_next) --- 5 unchanged lines hidden (view full) --- 1299 *frghdrp = 1300 (struct ip6_frag *)(mtod(mlast, caddr_t) + mlast->m_len); 1301 mlast->m_len += sizeof(struct ip6_frag); 1302 m->m_pkthdr.len += sizeof(struct ip6_frag); 1303 } else { 1304 /* allocate a new mbuf for the fragment header */ 1305 struct mbuf *mfrg; 1306 | 1286 if (n == 0) 1287 return(ENOBUFS); 1288 m->m_next = n; 1289 } else 1290 n = m; 1291 1292 /* Search for the last mbuf of unfragmentable part. */ 1293 for (mlast = n; mlast->m_next; mlast = mlast->m_next) --- 5 unchanged lines hidden (view full) --- 1299 *frghdrp = 1300 (struct ip6_frag *)(mtod(mlast, caddr_t) + mlast->m_len); 1301 mlast->m_len += sizeof(struct ip6_frag); 1302 m->m_pkthdr.len += sizeof(struct ip6_frag); 1303 } else { 1304 /* allocate a new mbuf for the fragment header */ 1305 struct mbuf *mfrg; 1306 |
1307 MGET(mfrg, M_DONTWAIT, MT_DATA); | 1307 MGET(mfrg, M_NOWAIT, MT_DATA); |
1308 if (mfrg == 0) 1309 return(ENOBUFS); 1310 mfrg->m_len = sizeof(struct ip6_frag); 1311 *frghdrp = mtod(mfrg, struct ip6_frag *); 1312 mlast->m_next = mfrg; 1313 } 1314 1315 return(0); --- 175 unchanged lines hidden (view full) --- 1491 case IPV6_LEAVE_GROUP: 1492 { 1493 struct mbuf *m; 1494 if (sopt->sopt_valsize > MLEN) { 1495 error = EMSGSIZE; 1496 break; 1497 } 1498 /* XXX */ | 1308 if (mfrg == 0) 1309 return(ENOBUFS); 1310 mfrg->m_len = sizeof(struct ip6_frag); 1311 *frghdrp = mtod(mfrg, struct ip6_frag *); 1312 mlast->m_next = mfrg; 1313 } 1314 1315 return(0); --- 175 unchanged lines hidden (view full) --- 1491 case IPV6_LEAVE_GROUP: 1492 { 1493 struct mbuf *m; 1494 if (sopt->sopt_valsize > MLEN) { 1495 error = EMSGSIZE; 1496 break; 1497 } 1498 /* XXX */ |
1499 MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_HEADER); | 1499 MGET(m, sopt->sopt_td ? 0 : M_NOWAIT, MT_HEADER); |
1500 if (m == 0) { 1501 error = ENOBUFS; 1502 break; 1503 } 1504 m->m_len = sopt->sopt_valsize; 1505 error = sooptcopyin(sopt, mtod(m, char *), 1506 m->m_len, m->m_len); 1507 error = ip6_setmoptions(sopt->sopt_name, --- 82 unchanged lines hidden (view full) --- 1590 1591 case SOPT_GET: 1592 switch (optname) { 1593 1594 case IPV6_PKTOPTIONS: 1595 if (in6p->in6p_options) { 1596 struct mbuf *m; 1597 m = m_copym(in6p->in6p_options, | 1500 if (m == 0) { 1501 error = ENOBUFS; 1502 break; 1503 } 1504 m->m_len = sopt->sopt_valsize; 1505 error = sooptcopyin(sopt, mtod(m, char *), 1506 m->m_len, m->m_len); 1507 error = ip6_setmoptions(sopt->sopt_name, --- 82 unchanged lines hidden (view full) --- 1590 1591 case SOPT_GET: 1592 switch (optname) { 1593 1594 case IPV6_PKTOPTIONS: 1595 if (in6p->in6p_options) { 1596 struct mbuf *m; 1597 m = m_copym(in6p->in6p_options, |
1598 0, M_COPYALL, M_TRYWAIT); | 1598 0, M_COPYALL, 0); |
1599 error = soopt_mcopyout(sopt, m); 1600 if (error == 0) 1601 m_freem(m); 1602 } else 1603 sopt->sopt_valsize = 0; 1604 break; 1605 1606 case IPV6_UNICAST_HOPS: --- 164 unchanged lines hidden (view full) --- 1771#ifdef DIAGNOSTIC 1772 if (opt->ip6po_pktinfo || opt->ip6po_nexthop || 1773 opt->ip6po_hbh || opt->ip6po_dest1 || opt->ip6po_dest2 || 1774 opt->ip6po_rhinfo.ip6po_rhi_rthdr) 1775 printf("ip6_pcbopts: all specified options are cleared.\n"); 1776#endif 1777 ip6_clearpktopts(opt, 1, -1); 1778 } else | 1599 error = soopt_mcopyout(sopt, m); 1600 if (error == 0) 1601 m_freem(m); 1602 } else 1603 sopt->sopt_valsize = 0; 1604 break; 1605 1606 case IPV6_UNICAST_HOPS: --- 164 unchanged lines hidden (view full) --- 1771#ifdef DIAGNOSTIC 1772 if (opt->ip6po_pktinfo || opt->ip6po_nexthop || 1773 opt->ip6po_hbh || opt->ip6po_dest1 || opt->ip6po_dest2 || 1774 opt->ip6po_rhinfo.ip6po_rhi_rthdr) 1775 printf("ip6_pcbopts: all specified options are cleared.\n"); 1776#endif 1777 ip6_clearpktopts(opt, 1, -1); 1778 } else |
1779 opt = malloc(sizeof(*opt), M_IP6OPT, M_WAITOK); | 1779 opt = malloc(sizeof(*opt), M_IP6OPT, 0); |
1780 *pktopt = NULL; 1781 1782 if (!m || m->m_len == 0) { 1783 /* 1784 * Only turning off any previous options, regardless of 1785 * whether the opt is just created or given. 1786 */ 1787 free(opt, M_IP6OPT); --- 166 unchanged lines hidden (view full) --- 1954 struct thread *td = curthread; /* XXX */ 1955 1956 if (im6o == NULL) { 1957 /* 1958 * No multicast option buffer attached to the pcb; 1959 * allocate one and initialize to default values. 1960 */ 1961 im6o = (struct ip6_moptions *) | 1780 *pktopt = NULL; 1781 1782 if (!m || m->m_len == 0) { 1783 /* 1784 * Only turning off any previous options, regardless of 1785 * whether the opt is just created or given. 1786 */ 1787 free(opt, M_IP6OPT); --- 166 unchanged lines hidden (view full) --- 1954 struct thread *td = curthread; /* XXX */ 1955 1956 if (im6o == NULL) { 1957 /* 1958 * No multicast option buffer attached to the pcb; 1959 * allocate one and initialize to default values. 1960 */ 1961 im6o = (struct ip6_moptions *) |
1962 malloc(sizeof(*im6o), M_IPMOPTS, M_WAITOK); | 1962 malloc(sizeof(*im6o), M_IPMOPTS, 0); |
1963 1964 if (im6o == NULL) 1965 return(ENOBUFS); 1966 *im6op = im6o; 1967 im6o->im6o_multicast_ifp = NULL; 1968 im6o->im6o_multicast_hlim = ip6_defmcasthlim; 1969 im6o->im6o_multicast_loop = IPV6_DEFAULT_MULTICAST_LOOP; 1970 LIST_INIT(&im6o->im6o_memberships); --- 153 unchanged lines hidden (view full) --- 2124 if (imm != NULL) { 2125 error = EADDRINUSE; 2126 break; 2127 } 2128 /* 2129 * Everything looks good; add a new record to the multicast 2130 * address list for the given interface. 2131 */ | 1963 1964 if (im6o == NULL) 1965 return(ENOBUFS); 1966 *im6op = im6o; 1967 im6o->im6o_multicast_ifp = NULL; 1968 im6o->im6o_multicast_hlim = ip6_defmcasthlim; 1969 im6o->im6o_multicast_loop = IPV6_DEFAULT_MULTICAST_LOOP; 1970 LIST_INIT(&im6o->im6o_memberships); --- 153 unchanged lines hidden (view full) --- 2124 if (imm != NULL) { 2125 error = EADDRINUSE; 2126 break; 2127 } 2128 /* 2129 * Everything looks good; add a new record to the multicast 2130 * address list for the given interface. 2131 */ |
2132 imm = malloc(sizeof(*imm), M_IPMADDR, M_WAITOK); | 2132 imm = malloc(sizeof(*imm), M_IPMADDR, 0); |
2133 if (imm == NULL) { 2134 error = ENOBUFS; 2135 break; 2136 } 2137 if ((imm->i6mm_maddr = 2138 in6_addmulti(&mreq->ipv6mr_multiaddr, ifp, &error)) == NULL) { 2139 free(imm, M_IPMADDR); 2140 break; --- 88 unchanged lines hidden (view full) --- 2229static int 2230ip6_getmoptions(optname, im6o, mp) 2231 int optname; 2232 struct ip6_moptions *im6o; 2233 struct mbuf **mp; 2234{ 2235 u_int *hlim, *loop, *ifindex; 2236 | 2133 if (imm == NULL) { 2134 error = ENOBUFS; 2135 break; 2136 } 2137 if ((imm->i6mm_maddr = 2138 in6_addmulti(&mreq->ipv6mr_multiaddr, ifp, &error)) == NULL) { 2139 free(imm, M_IPMADDR); 2140 break; --- 88 unchanged lines hidden (view full) --- 2229static int 2230ip6_getmoptions(optname, im6o, mp) 2231 int optname; 2232 struct ip6_moptions *im6o; 2233 struct mbuf **mp; 2234{ 2235 u_int *hlim, *loop, *ifindex; 2236 |
2237 *mp = m_get(M_TRYWAIT, MT_HEADER); /* XXX */ | 2237 *mp = m_get(0, MT_HEADER); /* XXX */ |
2238 2239 switch (optname) { 2240 2241 case IPV6_MULTICAST_IF: 2242 ifindex = mtod(*mp, u_int *); 2243 (*mp)->m_len = sizeof(u_int); 2244 if (im6o == NULL || im6o->im6o_multicast_ifp == NULL) 2245 *ifindex = 0; --- 82 unchanged lines hidden (view full) --- 2328 switch (cm->cmsg_type) { 2329 case IPV6_PKTINFO: 2330 if (cm->cmsg_len != CMSG_LEN(sizeof(struct in6_pktinfo))) 2331 return(EINVAL); 2332 if (needcopy) { 2333 /* XXX: Is it really WAITOK? */ 2334 opt->ip6po_pktinfo = 2335 malloc(sizeof(struct in6_pktinfo), | 2238 2239 switch (optname) { 2240 2241 case IPV6_MULTICAST_IF: 2242 ifindex = mtod(*mp, u_int *); 2243 (*mp)->m_len = sizeof(u_int); 2244 if (im6o == NULL || im6o->im6o_multicast_ifp == NULL) 2245 *ifindex = 0; --- 82 unchanged lines hidden (view full) --- 2328 switch (cm->cmsg_type) { 2329 case IPV6_PKTINFO: 2330 if (cm->cmsg_len != CMSG_LEN(sizeof(struct in6_pktinfo))) 2331 return(EINVAL); 2332 if (needcopy) { 2333 /* XXX: Is it really WAITOK? */ 2334 opt->ip6po_pktinfo = 2335 malloc(sizeof(struct in6_pktinfo), |
2336 M_IP6OPT, M_WAITOK); | 2336 M_IP6OPT, 0); |
2337 bcopy(CMSG_DATA(cm), opt->ip6po_pktinfo, 2338 sizeof(struct in6_pktinfo)); 2339 } else 2340 opt->ip6po_pktinfo = 2341 (struct in6_pktinfo *)CMSG_DATA(cm); 2342 if (opt->ip6po_pktinfo->ipi6_ifindex && 2343 IN6_IS_ADDR_LINKLOCAL(&opt->ip6po_pktinfo->ipi6_addr)) 2344 opt->ip6po_pktinfo->ipi6_addr.s6_addr16[1] = --- 42 unchanged lines hidden (view full) --- 2387 if (cm->cmsg_len < sizeof(u_char) || 2388 /* check if cmsg_len is large enough for sa_len */ 2389 cm->cmsg_len < CMSG_LEN(*CMSG_DATA(cm))) 2390 return(EINVAL); 2391 2392 if (needcopy) { 2393 opt->ip6po_nexthop = 2394 malloc(*CMSG_DATA(cm), | 2337 bcopy(CMSG_DATA(cm), opt->ip6po_pktinfo, 2338 sizeof(struct in6_pktinfo)); 2339 } else 2340 opt->ip6po_pktinfo = 2341 (struct in6_pktinfo *)CMSG_DATA(cm); 2342 if (opt->ip6po_pktinfo->ipi6_ifindex && 2343 IN6_IS_ADDR_LINKLOCAL(&opt->ip6po_pktinfo->ipi6_addr)) 2344 opt->ip6po_pktinfo->ipi6_addr.s6_addr16[1] = --- 42 unchanged lines hidden (view full) --- 2387 if (cm->cmsg_len < sizeof(u_char) || 2388 /* check if cmsg_len is large enough for sa_len */ 2389 cm->cmsg_len < CMSG_LEN(*CMSG_DATA(cm))) 2390 return(EINVAL); 2391 2392 if (needcopy) { 2393 opt->ip6po_nexthop = 2394 malloc(*CMSG_DATA(cm), |
2395 M_IP6OPT, M_WAITOK); | 2395 M_IP6OPT, 0); |
2396 bcopy(CMSG_DATA(cm), 2397 opt->ip6po_nexthop, 2398 *CMSG_DATA(cm)); 2399 } else 2400 opt->ip6po_nexthop = 2401 (struct sockaddr *)CMSG_DATA(cm); 2402 break; 2403 --- 6 unchanged lines hidden (view full) --- 2410 return(EINVAL); 2411 hbh = (struct ip6_hbh *)CMSG_DATA(cm); 2412 hbhlen = (hbh->ip6h_len + 1) << 3; 2413 if (cm->cmsg_len != CMSG_LEN(hbhlen)) 2414 return(EINVAL); 2415 2416 if (needcopy) { 2417 opt->ip6po_hbh = | 2396 bcopy(CMSG_DATA(cm), 2397 opt->ip6po_nexthop, 2398 *CMSG_DATA(cm)); 2399 } else 2400 opt->ip6po_nexthop = 2401 (struct sockaddr *)CMSG_DATA(cm); 2402 break; 2403 --- 6 unchanged lines hidden (view full) --- 2410 return(EINVAL); 2411 hbh = (struct ip6_hbh *)CMSG_DATA(cm); 2412 hbhlen = (hbh->ip6h_len + 1) << 3; 2413 if (cm->cmsg_len != CMSG_LEN(hbhlen)) 2414 return(EINVAL); 2415 2416 if (needcopy) { 2417 opt->ip6po_hbh = |
2418 malloc(hbhlen, M_IP6OPT, M_WAITOK); | 2418 malloc(hbhlen, M_IP6OPT, 0); |
2419 bcopy(hbh, opt->ip6po_hbh, hbhlen); 2420 } else 2421 opt->ip6po_hbh = hbh; 2422 break; 2423 } 2424 2425 case IPV6_DSTOPTS: 2426 { --- 21 unchanged lines hidden (view full) --- 2448 * introducing separate cmsg types. 2449 */ 2450 if (opt->ip6po_rthdr == NULL) 2451 newdest = &opt->ip6po_dest1; 2452 else 2453 newdest = &opt->ip6po_dest2; 2454 2455 if (needcopy) { | 2419 bcopy(hbh, opt->ip6po_hbh, hbhlen); 2420 } else 2421 opt->ip6po_hbh = hbh; 2422 break; 2423 } 2424 2425 case IPV6_DSTOPTS: 2426 { --- 21 unchanged lines hidden (view full) --- 2448 * introducing separate cmsg types. 2449 */ 2450 if (opt->ip6po_rthdr == NULL) 2451 newdest = &opt->ip6po_dest1; 2452 else 2453 newdest = &opt->ip6po_dest2; 2454 2455 if (needcopy) { |
2456 *newdest = malloc(destlen, M_IP6OPT, M_WAITOK); | 2456 *newdest = malloc(destlen, M_IP6OPT, 0); |
2457 bcopy(dest, *newdest, destlen); 2458 } else 2459 *newdest = dest; 2460 2461 break; 2462 } 2463 2464 case IPV6_RTHDR: --- 20 unchanged lines hidden (view full) --- 2485 return(EINVAL); 2486 break; 2487 default: 2488 return(EINVAL); /* not supported */ 2489 } 2490 2491 if (needcopy) { 2492 opt->ip6po_rthdr = malloc(rthlen, M_IP6OPT, | 2457 bcopy(dest, *newdest, destlen); 2458 } else 2459 *newdest = dest; 2460 2461 break; 2462 } 2463 2464 case IPV6_RTHDR: --- 20 unchanged lines hidden (view full) --- 2485 return(EINVAL); 2486 break; 2487 default: 2488 return(EINVAL); /* not supported */ 2489 } 2490 2491 if (needcopy) { 2492 opt->ip6po_rthdr = malloc(rthlen, M_IP6OPT, |
2493 M_WAITOK); | 2493 0); |
2494 bcopy(rth, opt->ip6po_rthdr, rthlen); 2495 } else 2496 opt->ip6po_rthdr = rth; 2497 2498 break; 2499 } 2500 2501 default: --- 63 unchanged lines hidden (view full) --- 2565 struct mbuf *m; 2566 struct ip6_exthdrs *exthdrs; 2567{ 2568 struct mbuf *mh; 2569 struct ip6_hdr *ip6; 2570 2571 ip6 = mtod(m, struct ip6_hdr *); 2572 if (m->m_len > sizeof(*ip6)) { | 2494 bcopy(rth, opt->ip6po_rthdr, rthlen); 2495 } else 2496 opt->ip6po_rthdr = rth; 2497 2498 break; 2499 } 2500 2501 default: --- 63 unchanged lines hidden (view full) --- 2565 struct mbuf *m; 2566 struct ip6_exthdrs *exthdrs; 2567{ 2568 struct mbuf *mh; 2569 struct ip6_hdr *ip6; 2570 2571 ip6 = mtod(m, struct ip6_hdr *); 2572 if (m->m_len > sizeof(*ip6)) { |
2573 MGETHDR(mh, M_DONTWAIT, MT_HEADER); | 2573 MGETHDR(mh, M_NOWAIT, MT_HEADER); |
2574 if (mh == 0) { 2575 m_freem(m); 2576 return ENOBUFS; 2577 } 2578 M_MOVE_PKTHDR(mh, m); 2579 MH_ALIGN(mh, sizeof(*ip6)); 2580 m->m_len -= sizeof(*ip6); 2581 m->m_data += sizeof(*ip6); --- 34 unchanged lines hidden --- | 2574 if (mh == 0) { 2575 m_freem(m); 2576 return ENOBUFS; 2577 } 2578 M_MOVE_PKTHDR(mh, m); 2579 MH_ALIGN(mh, sizeof(*ip6)); 2580 m->m_len -= sizeof(*ip6); 2581 m->m_data += sizeof(*ip6); --- 34 unchanged lines hidden --- |