Skip to content

Commit

Permalink
Make the ng_ether(4) node type dynamically loadable like the rest.
Browse files Browse the repository at this point in the history
This means 'options NETGRAPH' is no longer necessary in order to get
netgraph-enabled Ethernet interfaces. This supports loading/unloading
the ng_ether.ko and attaching/detaching the Ethernet interface in any
order.

Add two new hooks 'upper' and 'lower' to allow access to the protocol
demux engine and the raw device, respectively. This enables bridging
to be defined as a netgraph node, if so desired.

Reviewed by:	[email protected]
  • Loading branch information
Archie Cobbs authored and Archie Cobbs committed Jun 26, 2000
1 parent 29f42a6 commit e1e1452
Show file tree
Hide file tree
Showing 9 changed files with 769 additions and 435 deletions.
1 change: 1 addition & 0 deletions sys/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ netgraph/ng_bpf.c optional netgraph_bpf
net/bpf_filter.c optional netgraph_bpf
netgraph/ng_cisco.c optional netgraph_cisco
netgraph/ng_echo.c optional netgraph_echo
netgraph/ng_ether.c optional netgraph_ether
netgraph/ng_frame_relay.c optional netgraph_frame_relay
netgraph/ng_hole.c optional netgraph_hole
netgraph/ng_iface.c optional netgraph_iface
Expand Down
1 change: 1 addition & 0 deletions sys/conf/options
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ NETGRAPH_ASYNC opt_netgraph.h
NETGRAPH_BPF opt_netgraph.h
NETGRAPH_CISCO opt_netgraph.h
NETGRAPH_ECHO opt_netgraph.h
NETGRAPH_ETHER opt_netgraph.h
NETGRAPH_FRAME_RELAY opt_netgraph.h
NETGRAPH_HOLE opt_netgraph.h
NETGRAPH_IFACE opt_netgraph.h
Expand Down
16 changes: 14 additions & 2 deletions sys/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ struct ether_addr {
#define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)

#ifndef _KERNEL
#ifdef _KERNEL

extern void (*ng_ether_input_p)(struct ifnet *ifp,
struct mbuf **mp, struct ether_header *eh);
extern void (*ng_ether_input_orphan_p)(struct ifnet *ifp,
struct mbuf *m, struct ether_header *eh);
extern int (*ng_ether_output_p)(struct ifnet *ifp, struct mbuf **mp);
extern void (*ng_ether_attach_p)(struct ifnet *ifp);
extern void (*ng_ether_detach_p)(struct ifnet *ifp);

#else /* _KERNEL */

#include <sys/cdefs.h>

/*
Expand All @@ -93,6 +104,7 @@ int ether_line __P((char *, struct ether_addr *, char *));
char *ether_ntoa __P((struct ether_addr *));
int ether_ntohost __P((char *, struct ether_addr *));
__END_DECLS
#endif

#endif /* !_KERNEL */

#endif /* !_NET_ETHERNET_H_ */
12 changes: 12 additions & 0 deletions sys/net/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/radix.h>
#include <net/route.h>

Expand Down Expand Up @@ -235,6 +236,17 @@ if_detach(ifp)
s = splnet();
if_down(ifp);

/*
* Do any type-specific detach operation
*/
switch (ifp->if_type) {
case IFT_ETHER:
ether_ifdetach(ifp);
break;
default:
break;
}

/*
* Remove address from ifnet_addrs[] and maybe decrement if_index.
* Clean up all addresses.
Expand Down
4 changes: 1 addition & 3 deletions sys/net/if_arp.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ struct arpcom {
struct ifnet ac_if; /* network-visible interface */
u_char ac_enaddr[6]; /* ethernet hardware address */
int ac_multicnt; /* length of ac_multiaddrs list */
/* #ifdef NETGRAPH */
void *ac_ng; /* hook to hang netgraph stuff off */
/* #endif */
void *ac_netgraph; /* ng_ether(4) netgraph node info */
};

extern u_char etherbroadcastaddr[6];
Expand Down
Loading

0 comments on commit e1e1452

Please sign in to comment.