raw_ip.c (84e51a1b679bececc13cbe3cd3cb9b7d461b9fe7) raw_ip.c (ae19083248ad6d932f1636b743a64a319e31235d)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

449 ip->ip_tos = inp->inp_ip_tos;
450 if (inp->inp_flags & INP_DONTFRAG)
451 ip->ip_off = htons(IP_DF);
452 else
453 ip->ip_off = htons(0);
454 ip->ip_p = inp->inp_ip_p;
455 ip->ip_len = htons(m->m_pkthdr.len);
456 ip->ip_src = inp->inp_laddr;
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

449 ip->ip_tos = inp->inp_ip_tos;
450 if (inp->inp_flags & INP_DONTFRAG)
451 ip->ip_off = htons(IP_DF);
452 else
453 ip->ip_off = htons(0);
454 ip->ip_p = inp->inp_ip_p;
455 ip->ip_len = htons(m->m_pkthdr.len);
456 ip->ip_src = inp->inp_laddr;
457 ip->ip_dst.s_addr = dst;
457 if (jailed(inp->inp_cred)) {
458 /*
459 * prison_local_ip4() would be good enough but would
460 * let a source of INADDR_ANY pass, which we do not
458 if (jailed(inp->inp_cred)) {
459 /*
460 * prison_local_ip4() would be good enough but would
461 * let a source of INADDR_ANY pass, which we do not
461 * want to see from jails. We do not go through the
462 * pain of in_pcbladdr() for raw sockets.
462 * want to see from jails.
463 */
463 */
464 if (ip->ip_src.s_addr == INADDR_ANY)
465 error = prison_get_ip4(inp->inp_cred,
466 &ip->ip_src);
467 else
464 if (ip->ip_src.s_addr == INADDR_ANY) {
465 error = in_pcbladdr(inp, &ip->ip_dst, &ip->ip_src,
466 inp->inp_cred);
467 } else {
468 error = prison_local_ip4(inp->inp_cred,
469 &ip->ip_src);
468 error = prison_local_ip4(inp->inp_cred,
469 &ip->ip_src);
470 }
470 if (error != 0) {
471 INP_RUNLOCK(inp);
472 m_freem(m);
473 return (error);
474 }
475 }
471 if (error != 0) {
472 INP_RUNLOCK(inp);
473 m_freem(m);
474 return (error);
475 }
476 }
476 ip->ip_dst.s_addr = dst;
477 ip->ip_ttl = inp->inp_ip_ttl;
478 } else {
479 if (m->m_pkthdr.len > IP_MAXPACKET) {
480 m_freem(m);
481 return(EMSGSIZE);
482 }
483 INP_RLOCK(inp);
484 ip = mtod(m, struct ip *);

--- 643 unchanged lines hidden ---
477 ip->ip_ttl = inp->inp_ip_ttl;
478 } else {
479 if (m->m_pkthdr.len > IP_MAXPACKET) {
480 m_freem(m);
481 return(EMSGSIZE);
482 }
483 INP_RLOCK(inp);
484 ip = mtod(m, struct ip *);

--- 643 unchanged lines hidden ---