Deleted Added
full compact
raw_ip.c (222143) raw_ip.c (222488)
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:

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

26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
31 */
32
33#include <sys/cdefs.h>
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:

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

26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/raw_ip.c 222143 2011-05-20 19:12:20Z qingli $");
34__FBSDID("$FreeBSD: head/sys/netinet/raw_ip.c 222488 2011-05-30 09:43:55Z rwatson $");
35
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
39
40#include <sys/param.h>
41#include <sys/jail.h>
42#include <sys/kernel.h>

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

221
222#ifdef INET
223static int
224rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
225 struct sockaddr_in *ripsrc)
226{
227 int policyfail = 0;
228
35
36#include "opt_inet.h"
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
39
40#include <sys/param.h>
41#include <sys/jail.h>
42#include <sys/kernel.h>

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

221
222#ifdef INET
223static int
224rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
225 struct sockaddr_in *ripsrc)
226{
227 int policyfail = 0;
228
229 INP_RLOCK_ASSERT(last);
229 INP_LOCK_ASSERT(last);
230
231#ifdef IPSEC
232 /* check AH/ESP integrity. */
233 if (ipsec4_in_reject(n, last)) {
234 policyfail = 1;
235 }
236#endif /* IPSEC */
237#ifdef MAC

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

829 in_pcbdetach(inp);
830 in_pcbfree(inp);
831 INP_INFO_WUNLOCK(&V_ripcbinfo);
832}
833
834static void
835rip_dodisconnect(struct socket *so, struct inpcb *inp)
836{
230
231#ifdef IPSEC
232 /* check AH/ESP integrity. */
233 if (ipsec4_in_reject(n, last)) {
234 policyfail = 1;
235 }
236#endif /* IPSEC */
237#ifdef MAC

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

829 in_pcbdetach(inp);
830 in_pcbfree(inp);
831 INP_INFO_WUNLOCK(&V_ripcbinfo);
832}
833
834static void
835rip_dodisconnect(struct socket *so, struct inpcb *inp)
836{
837 struct inpcbinfo *pcbinfo;
837
838
838 INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
839 INP_WLOCK_ASSERT(inp);
840
839 pcbinfo = inp->inp_pcbinfo;
840 INP_INFO_WLOCK(pcbinfo);
841 INP_WLOCK(inp);
841 rip_delhash(inp);
842 inp->inp_faddr.s_addr = INADDR_ANY;
843 rip_inshash(inp);
844 SOCK_LOCK(so);
845 so->so_state &= ~SS_ISCONNECTED;
846 SOCK_UNLOCK(so);
842 rip_delhash(inp);
843 inp->inp_faddr.s_addr = INADDR_ANY;
844 rip_inshash(inp);
845 SOCK_LOCK(so);
846 so->so_state &= ~SS_ISCONNECTED;
847 SOCK_UNLOCK(so);
848 INP_WUNLOCK(inp);
849 INP_INFO_WUNLOCK(pcbinfo);
847}
848
849static void
850rip_abort(struct socket *so)
851{
852 struct inpcb *inp;
853
854 inp = sotoinpcb(so);
855 KASSERT(inp != NULL, ("rip_abort: inp == NULL"));
856
850}
851
852static void
853rip_abort(struct socket *so)
854{
855 struct inpcb *inp;
856
857 inp = sotoinpcb(so);
858 KASSERT(inp != NULL, ("rip_abort: inp == NULL"));
859
857 INP_INFO_WLOCK(&V_ripcbinfo);
858 INP_WLOCK(inp);
859 rip_dodisconnect(so, inp);
860 rip_dodisconnect(so, inp);
860 INP_WUNLOCK(inp);
861 INP_INFO_WUNLOCK(&V_ripcbinfo);
862}
863
864static void
865rip_close(struct socket *so)
866{
867 struct inpcb *inp;
868
869 inp = sotoinpcb(so);
870 KASSERT(inp != NULL, ("rip_close: inp == NULL"));
871
861}
862
863static void
864rip_close(struct socket *so)
865{
866 struct inpcb *inp;
867
868 inp = sotoinpcb(so);
869 KASSERT(inp != NULL, ("rip_close: inp == NULL"));
870
872 INP_INFO_WLOCK(&V_ripcbinfo);
873 INP_WLOCK(inp);
874 rip_dodisconnect(so, inp);
871 rip_dodisconnect(so, inp);
875 INP_WUNLOCK(inp);
876 INP_INFO_WUNLOCK(&V_ripcbinfo);
877}
878
879static int
880rip_disconnect(struct socket *so)
881{
882 struct inpcb *inp;
883
884 if ((so->so_state & SS_ISCONNECTED) == 0)
885 return (ENOTCONN);
886
887 inp = sotoinpcb(so);
888 KASSERT(inp != NULL, ("rip_disconnect: inp == NULL"));
889
872}
873
874static int
875rip_disconnect(struct socket *so)
876{
877 struct inpcb *inp;
878
879 if ((so->so_state & SS_ISCONNECTED) == 0)
880 return (ENOTCONN);
881
882 inp = sotoinpcb(so);
883 KASSERT(inp != NULL, ("rip_disconnect: inp == NULL"));
884
890 INP_INFO_WLOCK(&V_ripcbinfo);
891 INP_WLOCK(inp);
892 rip_dodisconnect(so, inp);
885 rip_dodisconnect(so, inp);
893 INP_WUNLOCK(inp);
894 INP_INFO_WUNLOCK(&V_ripcbinfo);
895 return (0);
896}
897
898static int
899rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
900{
901 struct sockaddr_in *addr = (struct sockaddr_in *)nam;
902 struct inpcb *inp;

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

1072 INP_RUNLOCK(inp);
1073 error = SYSCTL_OUT(req, &xi, sizeof xi);
1074 } else
1075 INP_RUNLOCK(inp);
1076 }
1077 INP_INFO_WLOCK(&V_ripcbinfo);
1078 for (i = 0; i < n; i++) {
1079 inp = inp_list[i];
886 return (0);
887}
888
889static int
890rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
891{
892 struct sockaddr_in *addr = (struct sockaddr_in *)nam;
893 struct inpcb *inp;

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

1063 INP_RUNLOCK(inp);
1064 error = SYSCTL_OUT(req, &xi, sizeof xi);
1065 } else
1066 INP_RUNLOCK(inp);
1067 }
1068 INP_INFO_WLOCK(&V_ripcbinfo);
1069 for (i = 0; i < n; i++) {
1070 inp = inp_list[i];
1080 INP_WLOCK(inp);
1081 if (!in_pcbrele(inp))
1082 INP_WUNLOCK(inp);
1071 INP_RLOCK(inp);
1072 if (!in_pcbrele_rlocked(inp))
1073 INP_RUNLOCK(inp);
1083 }
1084 INP_INFO_WUNLOCK(&V_ripcbinfo);
1085
1086 if (!error) {
1087 /*
1088 * Give the user an updated idea of our state. If the
1089 * generation differs from what we told her before, she knows
1090 * that something happened while we were processing this

--- 34 unchanged lines hidden ---
1074 }
1075 INP_INFO_WUNLOCK(&V_ripcbinfo);
1076
1077 if (!error) {
1078 /*
1079 * Give the user an updated idea of our state. If the
1080 * generation differs from what we told her before, she knows
1081 * that something happened while we were processing this

--- 34 unchanged lines hidden ---