raw_ip.c (b8103ca76de09414775aa2eaca7b0e1bca59136c) | raw_ip.c (3d2041c0353d3cc44bd2a6e37bf1c6e341d2b4db) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1982, 1986, 1988, 1993 5 * The Regents of the University of California. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 392 unchanged lines hidden (view full) --- 401 m_freem(m); 402 return (IPPROTO_DONE); 403} 404 405/* 406 * Generate IP header and pass packet to ip_output. Tack on options user may 407 * have setup with control call. 408 */ | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1982, 1986, 1988, 1993 5 * The Regents of the University of California. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 392 unchanged lines hidden (view full) --- 401 m_freem(m); 402 return (IPPROTO_DONE); 403} 404 405/* 406 * Generate IP header and pass packet to ip_output. Tack on options user may 407 * have setup with control call. 408 */ |
409int 410rip_output(struct mbuf *m, struct socket *so, ...) | 409static int 410rip_send(struct socket *so, int pruflags, struct mbuf *m, struct sockaddr *nam, 411 struct mbuf *control, struct thread *td) |
411{ 412 struct epoch_tracker et; 413 struct ip *ip; | 412{ 413 struct epoch_tracker et; 414 struct ip *ip; |
414 int error; 415 struct inpcb *inp = sotoinpcb(so); 416 va_list ap; 417 u_long dst; 418 int flags = ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0) | 419 IP_ALLOWBROADCAST; 420 int cnt, hlen; | 415 struct inpcb *inp; 416 in_addr_t *dst; 417 int error, flags, cnt, hlen; |
421 u_char opttype, optlen, *cp; 422 | 418 u_char opttype, optlen, *cp; 419 |
423 va_start(ap, so); 424 dst = va_arg(ap, u_long); 425 va_end(ap); | 420 inp = sotoinpcb(so); 421 KASSERT(inp != NULL, ("rip_send: inp == NULL")); |
426 | 422 |
423 if (control != NULL) { 424 m_freem(control); 425 control = NULL; 426 } 427 428 if (so->so_state & SS_ISCONNECTED) { 429 if (nam) { 430 error = EISCONN; 431 m_freem(m); 432 return (error); 433 } 434 dst = &inp->inp_faddr.s_addr; 435 } else { 436 if (nam == NULL) 437 error = ENOTCONN; 438 else if (nam->sa_family != AF_INET) 439 error = EAFNOSUPPORT; 440 else if (nam->sa_len != sizeof(struct sockaddr_in)) 441 error = EINVAL; 442 else 443 error = 0; 444 if (error != 0) { 445 m_freem(m); 446 return (error); 447 } 448 dst = &((struct sockaddr_in *)nam)->sin_addr.s_addr; 449 } 450 451 flags = ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0) | 452 IP_ALLOWBROADCAST; 453 |
|
427 /* 428 * If the user handed us a complete IP packet, use it. Otherwise, 429 * allocate an mbuf for a header and fill it in. 430 */ 431 if ((inp->inp_flags & INP_HDRINCL) == 0) { 432 if (m->m_pkthdr.len + sizeof(struct ip) > IP_MAXPACKET) { 433 m_freem(m); 434 return(EMSGSIZE); --- 7 unchanged lines hidden (view full) --- 442 ip->ip_tos = inp->inp_ip_tos; 443 if (inp->inp_flags & INP_DONTFRAG) 444 ip->ip_off = htons(IP_DF); 445 else 446 ip->ip_off = htons(0); 447 ip->ip_p = inp->inp_ip_p; 448 ip->ip_len = htons(m->m_pkthdr.len); 449 ip->ip_src = inp->inp_laddr; | 454 /* 455 * If the user handed us a complete IP packet, use it. Otherwise, 456 * allocate an mbuf for a header and fill it in. 457 */ 458 if ((inp->inp_flags & INP_HDRINCL) == 0) { 459 if (m->m_pkthdr.len + sizeof(struct ip) > IP_MAXPACKET) { 460 m_freem(m); 461 return(EMSGSIZE); --- 7 unchanged lines hidden (view full) --- 469 ip->ip_tos = inp->inp_ip_tos; 470 if (inp->inp_flags & INP_DONTFRAG) 471 ip->ip_off = htons(IP_DF); 472 else 473 ip->ip_off = htons(0); 474 ip->ip_p = inp->inp_ip_p; 475 ip->ip_len = htons(m->m_pkthdr.len); 476 ip->ip_src = inp->inp_laddr; |
450 ip->ip_dst.s_addr = dst; | 477 ip->ip_dst.s_addr = *dst; |
451#ifdef ROUTE_MPATH 452 if (CALC_FLOWID_OUTBOUND) { 453 uint32_t hash_type, hash_val; 454 455 hash_val = fib4_calc_software_hash(ip->ip_src, 456 ip->ip_dst, 0, 0, ip->ip_p, &hash_type); 457 m->m_pkthdr.flowid = hash_val; 458 M_HASHTYPE_SET(m, hash_type); --- 507 unchanged lines hidden (view full) --- 966 inp = sotoinpcb(so); 967 KASSERT(inp != NULL, ("rip_shutdown: inp == NULL")); 968 969 INP_WLOCK(inp); 970 socantsendmore(so); 971 INP_WUNLOCK(inp); 972 return (0); 973} | 478#ifdef ROUTE_MPATH 479 if (CALC_FLOWID_OUTBOUND) { 480 uint32_t hash_type, hash_val; 481 482 hash_val = fib4_calc_software_hash(ip->ip_src, 483 ip->ip_dst, 0, 0, ip->ip_p, &hash_type); 484 m->m_pkthdr.flowid = hash_val; 485 M_HASHTYPE_SET(m, hash_type); --- 507 unchanged lines hidden (view full) --- 993 inp = sotoinpcb(so); 994 KASSERT(inp != NULL, ("rip_shutdown: inp == NULL")); 995 996 INP_WLOCK(inp); 997 socantsendmore(so); 998 INP_WUNLOCK(inp); 999 return (0); 1000} |
974 975static int 976rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, 977 struct mbuf *control, struct thread *td) 978{ 979 struct inpcb *inp; 980 u_long dst; 981 int error; 982 983 inp = sotoinpcb(so); 984 KASSERT(inp != NULL, ("rip_send: inp == NULL")); 985 986 if (control != NULL) { 987 m_freem(control); 988 control = NULL; 989 } 990 991 /* 992 * Note: 'dst' reads below are unlocked. 993 */ 994 if (so->so_state & SS_ISCONNECTED) { 995 if (nam) { 996 error = EISCONN; 997 goto release; 998 } 999 dst = inp->inp_faddr.s_addr; /* Unlocked read. */ 1000 } else { 1001 error = 0; 1002 if (nam == NULL) 1003 error = ENOTCONN; 1004 else if (nam->sa_family != AF_INET) 1005 error = EAFNOSUPPORT; 1006 else if (nam->sa_len != sizeof(struct sockaddr_in)) 1007 error = EINVAL; 1008 if (error != 0) 1009 goto release; 1010 dst = ((struct sockaddr_in *)nam)->sin_addr.s_addr; 1011 } 1012 return (rip_output(m, so, dst)); 1013 1014release: 1015 m_freem(m); 1016 return (error); 1017} | |
1018#endif /* INET */ 1019 1020static int 1021rip_pcblist(SYSCTL_HANDLER_ARGS) 1022{ 1023 struct inpcb_iterator inpi = INP_ALL_ITERATOR(&V_ripcbinfo, 1024 INPLOOKUP_RLOCKPCB); 1025 struct xinpgen xig; --- 79 unchanged lines hidden --- | 1001#endif /* INET */ 1002 1003static int 1004rip_pcblist(SYSCTL_HANDLER_ARGS) 1005{ 1006 struct inpcb_iterator inpi = INP_ALL_ITERATOR(&V_ripcbinfo, 1007 INPLOOKUP_RLOCKPCB); 1008 struct xinpgen xig; --- 79 unchanged lines hidden --- |