Deleted Added
full compact
if_gre.c (241394) if_gre.c (241610)
1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */
1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */
2/* $FreeBSD: head/sys/net/if_gre.c 241394 2012-10-10 08:36:38Z kevlo $ */
2/* $FreeBSD: head/sys/net/if_gre.c 241610 2012-10-16 13:37:54Z glebius $ */
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *

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

85
86/*
87 * It is not easy to calculate the right value for a GRE MTU.
88 * We leave this task to the admin and use the same default that
89 * other vendors use.
90 */
91#define GREMTU 1476
92
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *

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

85
86/*
87 * It is not easy to calculate the right value for a GRE MTU.
88 * We leave this task to the admin and use the same default that
89 * other vendors use.
90 */
91#define GREMTU 1476
92
93#define GRENAME "gre"
94
95#define MTAG_COOKIE_GRE 1307983903
96#define MTAG_GRE_NESTING 1
97struct mtag_gre_nesting {
98 uint16_t count;
99 uint16_t max;
100 struct ifnet *ifp[];
101};
102
103/*
104 * gre_mtx protects all global variables in if_gre.c.
105 * XXX: gre_softc data not protected yet.
106 */
107struct mtx gre_mtx;
93#define MTAG_COOKIE_GRE 1307983903
94#define MTAG_GRE_NESTING 1
95struct mtag_gre_nesting {
96 uint16_t count;
97 uint16_t max;
98 struct ifnet *ifp[];
99};
100
101/*
102 * gre_mtx protects all global variables in if_gre.c.
103 * XXX: gre_softc data not protected yet.
104 */
105struct mtx gre_mtx;
108static MALLOC_DEFINE(M_GRE, GRENAME, "Generic Routing Encapsulation");
106static const char grename[] = "gre";
107static MALLOC_DEFINE(M_GRE, grename, "Generic Routing Encapsulation");
109
110struct gre_softc_head gre_softc_list;
111
112static int gre_clone_create(struct if_clone *, int, caddr_t);
113static void gre_clone_destroy(struct ifnet *);
108
109struct gre_softc_head gre_softc_list;
110
111static int gre_clone_create(struct if_clone *, int, caddr_t);
112static void gre_clone_destroy(struct ifnet *);
113static struct if_clone *gre_cloner;
114
114static int gre_ioctl(struct ifnet *, u_long, caddr_t);
115static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *,
116 struct route *ro);
117
115static int gre_ioctl(struct ifnet *, u_long, caddr_t);
116static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *,
117 struct route *ro);
118
118IFC_SIMPLE_DECLARE(gre, 0);
119
120static int gre_compute_route(struct gre_softc *sc);
121
122static void greattach(void);
123
124#ifdef INET
125extern struct domain inetdomain;
126static const struct protosw in_gre_protosw = {
127 .pr_type = SOCK_RAW,

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

167
168/* ARGSUSED */
169static void
170greattach(void)
171{
172
173 mtx_init(&gre_mtx, "gre_mtx", NULL, MTX_DEF);
174 LIST_INIT(&gre_softc_list);
119static int gre_compute_route(struct gre_softc *sc);
120
121static void greattach(void);
122
123#ifdef INET
124extern struct domain inetdomain;
125static const struct protosw in_gre_protosw = {
126 .pr_type = SOCK_RAW,

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

166
167/* ARGSUSED */
168static void
169greattach(void)
170{
171
172 mtx_init(&gre_mtx, "gre_mtx", NULL, MTX_DEF);
173 LIST_INIT(&gre_softc_list);
175 if_clone_attach(&gre_cloner);
174 gre_cloner = if_clone_simple(grename, gre_clone_create,
175 gre_clone_destroy, 0);
176}
177
178static int
179gre_clone_create(ifc, unit, params)
180 struct if_clone *ifc;
181 int unit;
182 caddr_t params;
183{
184 struct gre_softc *sc;
185
186 sc = malloc(sizeof(struct gre_softc), M_GRE, M_WAITOK | M_ZERO);
187
188 GRE2IFP(sc) = if_alloc(IFT_TUNNEL);
189 if (GRE2IFP(sc) == NULL) {
190 free(sc, M_GRE);
191 return (ENOSPC);
192 }
193
194 GRE2IFP(sc)->if_softc = sc;
176}
177
178static int
179gre_clone_create(ifc, unit, params)
180 struct if_clone *ifc;
181 int unit;
182 caddr_t params;
183{
184 struct gre_softc *sc;
185
186 sc = malloc(sizeof(struct gre_softc), M_GRE, M_WAITOK | M_ZERO);
187
188 GRE2IFP(sc) = if_alloc(IFT_TUNNEL);
189 if (GRE2IFP(sc) == NULL) {
190 free(sc, M_GRE);
191 return (ENOSPC);
192 }
193
194 GRE2IFP(sc)->if_softc = sc;
195 if_initname(GRE2IFP(sc), ifc->ifc_name, unit);
195 if_initname(GRE2IFP(sc), grename, unit);
196
197 GRE2IFP(sc)->if_snd.ifq_maxlen = ifqmaxlen;
198 GRE2IFP(sc)->if_addrlen = 0;
199 GRE2IFP(sc)->if_hdrlen = 24; /* IP + GRE */
200 GRE2IFP(sc)->if_mtu = GREMTU;
201 GRE2IFP(sc)->if_flags = IFF_POINTOPOINT|IFF_MULTICAST;
202 GRE2IFP(sc)->if_output = gre_output;
203 GRE2IFP(sc)->if_ioctl = gre_ioctl;

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

956gremodevent(module_t mod, int type, void *data)
957{
958
959 switch (type) {
960 case MOD_LOAD:
961 greattach();
962 break;
963 case MOD_UNLOAD:
196
197 GRE2IFP(sc)->if_snd.ifq_maxlen = ifqmaxlen;
198 GRE2IFP(sc)->if_addrlen = 0;
199 GRE2IFP(sc)->if_hdrlen = 24; /* IP + GRE */
200 GRE2IFP(sc)->if_mtu = GREMTU;
201 GRE2IFP(sc)->if_flags = IFF_POINTOPOINT|IFF_MULTICAST;
202 GRE2IFP(sc)->if_output = gre_output;
203 GRE2IFP(sc)->if_ioctl = gre_ioctl;

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

956gremodevent(module_t mod, int type, void *data)
957{
958
959 switch (type) {
960 case MOD_LOAD:
961 greattach();
962 break;
963 case MOD_UNLOAD:
964 if_clone_detach(&gre_cloner);
964 if_clone_detach(gre_cloner);
965 mtx_destroy(&gre_mtx);
966 break;
967 default:
968 return EOPNOTSUPP;
969 }
970 return 0;
971}
972
973static moduledata_t gre_mod = {
974 "if_gre",
975 gremodevent,
976 0
977};
978
979DECLARE_MODULE(if_gre, gre_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
980MODULE_VERSION(if_gre, 1);
965 mtx_destroy(&gre_mtx);
966 break;
967 default:
968 return EOPNOTSUPP;
969 }
970 return 0;
971}
972
973static moduledata_t gre_mod = {
974 "if_gre",
975 gremodevent,
976 0
977};
978
979DECLARE_MODULE(if_gre, gre_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
980MODULE_VERSION(if_gre, 1);