Deleted Added
full compact
if_loop.c (235960) if_loop.c (236170)
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)if_loop.c 8.2 (Berkeley) 1/9/95
1/*-
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)if_loop.c 8.2 (Berkeley) 1/9/95
30 * $FreeBSD: head/sys/net/if_loop.c 235960 2012-05-25 02:21:17Z bz $
30 * $FreeBSD: head/sys/net/if_loop.c 236170 2012-05-28 09:30:13Z bz $
31 */
32
33/*
34 * Loopback interface driver for protocol testing and timing.
35 */
36
37#include "opt_atalk.h"
38#include "opt_inet.h"

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

87#define LOMTU (1024+512)
88#elif defined(LARGE_LOMTU)
89#define LOMTU 131072
90#else
91#define LOMTU 16384
92#endif
93
94#define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP)
31 */
32
33/*
34 * Loopback interface driver for protocol testing and timing.
35 */
36
37#include "opt_atalk.h"
38#include "opt_inet.h"

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

87#define LOMTU (1024+512)
88#elif defined(LARGE_LOMTU)
89#define LOMTU 131072
90#else
91#define LOMTU 16384
92#endif
93
94#define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP)
95#define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_PSEUDO_HDR | \
95#define LO_CSUM_FEATURES6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_SCTP)
96#define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_DATA_VALID_IPV6 | \
97 CSUM_PSEUDO_HDR | \
96 CSUM_IP_CHECKED | CSUM_IP_VALID | \
97 CSUM_SCTP_VALID)
98
99int loioctl(struct ifnet *, u_long, caddr_t);
100static void lortrequest(int, struct rtentry *, struct rt_addrinfo *);
101int looutput(struct ifnet *ifp, struct mbuf *m,
102 struct sockaddr *dst, struct route *ro);
103static int lo_clone_create(struct if_clone *, int, caddr_t);

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

138 return (ENOSPC);
139
140 if_initname(ifp, ifc->ifc_name, unit);
141 ifp->if_mtu = LOMTU;
142 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
143 ifp->if_ioctl = loioctl;
144 ifp->if_output = looutput;
145 ifp->if_snd.ifq_maxlen = ifqmaxlen;
98 CSUM_IP_CHECKED | CSUM_IP_VALID | \
99 CSUM_SCTP_VALID)
100
101int loioctl(struct ifnet *, u_long, caddr_t);
102static void lortrequest(int, struct rtentry *, struct rt_addrinfo *);
103int looutput(struct ifnet *ifp, struct mbuf *m,
104 struct sockaddr *dst, struct route *ro);
105static int lo_clone_create(struct if_clone *, int, caddr_t);

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

140 return (ENOSPC);
141
142 if_initname(ifp, ifc->ifc_name, unit);
143 ifp->if_mtu = LOMTU;
144 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
145 ifp->if_ioctl = loioctl;
146 ifp->if_output = looutput;
147 ifp->if_snd.ifq_maxlen = ifqmaxlen;
146 ifp->if_capabilities = ifp->if_capenable = IFCAP_HWCSUM;
147 ifp->if_hwassist = LO_CSUM_FEATURES;
148 ifp->if_capabilities = ifp->if_capenable =
149 IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6;
150 ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6;
148 if_attach(ifp);
149 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
150 if (V_loif == NULL)
151 V_loif = ifp;
152
153 return (0);
154}
155

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

242 if (dst->sa_family == AF_UNSPEC) {
243 bcopy(dst->sa_data, &af, sizeof(af));
244 dst->sa_family = af;
245 }
246
247#if 1 /* XXX */
248 switch (dst->sa_family) {
249 case AF_INET:
151 if_attach(ifp);
152 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
153 if (V_loif == NULL)
154 V_loif = ifp;
155
156 return (0);
157}
158

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

245 if (dst->sa_family == AF_UNSPEC) {
246 bcopy(dst->sa_data, &af, sizeof(af));
247 dst->sa_family = af;
248 }
249
250#if 1 /* XXX */
251 switch (dst->sa_family) {
252 case AF_INET:
250 case AF_INET6:
251 if (ifp->if_capenable & IFCAP_RXCSUM) {
252 m->m_pkthdr.csum_data = 0xffff;
253 m->m_pkthdr.csum_flags = LO_CSUM_SET;
254 }
255 m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES;
253 if (ifp->if_capenable & IFCAP_RXCSUM) {
254 m->m_pkthdr.csum_data = 0xffff;
255 m->m_pkthdr.csum_flags = LO_CSUM_SET;
256 }
257 m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES;
258 break;
259 case AF_INET6:
260 if (ifp->if_capenable & IFCAP_RXCSUM_IPV6) {
261 m->m_pkthdr.csum_data = 0xffff;
262 m->m_pkthdr.csum_flags = LO_CSUM_SET;
263 }
264 m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES6;
265 break;
256 case AF_IPX:
257 case AF_APPLETALK:
258 break;
259 default:
260 printf("looutput: af=%d unexpected\n", dst->sa_family);
261 m_freem(m);
262 return (EAFNOSUPPORT);
263 }

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

431 break;
432
433 case SIOCSIFCAP:
434 mask = ifp->if_capenable ^ ifr->ifr_reqcap;
435 if ((mask & IFCAP_RXCSUM) != 0)
436 ifp->if_capenable ^= IFCAP_RXCSUM;
437 if ((mask & IFCAP_TXCSUM) != 0)
438 ifp->if_capenable ^= IFCAP_TXCSUM;
266 case AF_IPX:
267 case AF_APPLETALK:
268 break;
269 default:
270 printf("looutput: af=%d unexpected\n", dst->sa_family);
271 m_freem(m);
272 return (EAFNOSUPPORT);
273 }

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

441 break;
442
443 case SIOCSIFCAP:
444 mask = ifp->if_capenable ^ ifr->ifr_reqcap;
445 if ((mask & IFCAP_RXCSUM) != 0)
446 ifp->if_capenable ^= IFCAP_RXCSUM;
447 if ((mask & IFCAP_TXCSUM) != 0)
448 ifp->if_capenable ^= IFCAP_TXCSUM;
449 if ((mask & IFCAP_RXCSUM_IPV6) != 0)
450 ifp->if_capenable ^= IFCAP_RXCSUM_IPV6;
451 if ((mask & IFCAP_TXCSUM_IPV6) != 0)
452 ifp->if_capenable ^= IFCAP_TXCSUM_IPV6;
453 ifp->if_hwassist = 0;
439 if (ifp->if_capenable & IFCAP_TXCSUM)
440 ifp->if_hwassist = LO_CSUM_FEATURES;
454 if (ifp->if_capenable & IFCAP_TXCSUM)
455 ifp->if_hwassist = LO_CSUM_FEATURES;
441 else
442 ifp->if_hwassist = 0;
456 if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
457 ifp->if_hwassist |= LO_CSUM_FEATURES6;
443 break;
444
445 default:
446 error = EINVAL;
447 }
448 return (error);
449}
458 break;
459
460 default:
461 error = EINVAL;
462 }
463 return (error);
464}