Replace 'struct route *' if_output() argument with 'struct nhop_info *'.

Leave 'struct route' as is for legacy routing api users.
Remove most of rtalloc_ign*-derived functions.
This commit is contained in:
Alexander V. Chernikov 2014-11-09 16:33:04 +00:00
parent ea491b8afd
commit 033074c440
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/routing/; revision=274317
52 changed files with 153 additions and 199 deletions

View File

@ -101,7 +101,7 @@ static int icattach(device_t);
static int icioctl(struct ifnet *, u_long, caddr_t);
static int icoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
static int icintr(device_t, int, char *);
@ -352,7 +352,7 @@ icintr(device_t dev, int event, char *ptr)
*/
static int
icoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct ic_softc *sc = ifp->if_softc;
device_t icdev = sc->ic_dev;

View File

@ -3637,7 +3637,7 @@ lmc_ifnet_start(struct ifnet *ifp)
/* Called from a syscall (user context; no spinlocks). */
static int
lmc_raw_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
softc_t *sc = IFP2SC(ifp);
int error = 0;

View File

@ -1365,7 +1365,7 @@ static int lmc_raw_ioctl(struct ifnet *, u_long, caddr_t);
static int lmc_ifnet_ioctl(struct ifnet *, u_long, caddr_t);
static void lmc_ifnet_start(struct ifnet *);
static int lmc_raw_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static void setup_ifnet(struct ifnet *);
static int lmc_ifnet_attach(softc_t *);
static void lmc_ifnet_detach(softc_t *);

View File

@ -175,7 +175,7 @@ static u_char *ctxmith;
static int lpinittables(void);
static int lpioctl(struct ifnet *, u_long, caddr_t);
static int lpoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
static void lpstop(struct lp_data *);
static void lp_intr(void *);
static int lp_module_handler(module_t, int, void *);
@ -683,7 +683,7 @@ lpoutbyte(u_char byte, int spin, device_t ppbus)
static int
lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct lp_data *sc = ifp->if_softc;
device_t dev = sc->sc_dev;

View File

@ -126,7 +126,7 @@ static void usie_if_status_cb(void *, int);
static void usie_if_start(struct ifnet *);
static int usie_if_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static void usie_if_init(void *);
static void usie_if_stop(struct usie_softc *);
static int usie_if_ioctl(struct ifnet *, u_long, caddr_t);
@ -1187,7 +1187,7 @@ usie_if_start(struct ifnet *ifp)
static int
usie_if_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
int err;

View File

@ -471,7 +471,7 @@ static void uhso_if_start(struct ifnet *);
static void uhso_if_stop(struct uhso_softc *);
static int uhso_if_ioctl(struct ifnet *, u_long, caddr_t);
static int uhso_if_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static void uhso_if_rxflush(void *);
static device_probe_t uhso_probe;
@ -1883,7 +1883,7 @@ uhso_if_init(void *priv)
static int
uhso_if_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
int error;

View File

@ -138,7 +138,8 @@ struct wtap_softc {
(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]);
void (*sc_node_free)(struct ieee80211_node *);
int (*if_output) /* output routine (enqueue) */
(struct ifnet *, struct mbuf *, struct sockaddr *, struct route *);
(struct ifnet *, struct mbuf *, struct sockaddr *,
struct nhop_info *);
void (*if_input) (struct ifnet *, struct mbuf *);/* from h/w driver */
int (*if_transmit)(struct ifnet *, struct mbuf *);/* output routine */
struct mtx sc_mtx; /* master lock (recursive) */

View File

@ -365,7 +365,7 @@ struct ether_addr {
struct ifnet;
struct mbuf;
struct route;
struct nhop_info;
struct sockaddr;
struct bpf_if;
@ -376,7 +376,7 @@ extern void ether_ifattach(struct ifnet *, const u_int8_t *);
extern void ether_ifdetach(struct ifnet *);
extern int ether_ioctl(struct ifnet *, u_long, caddr_t);
extern int ether_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
extern int ether_output_frame(struct ifnet *, struct mbuf *);
extern char *ether_sprintf(const u_int8_t *);
void ether_vlan_mtap(struct bpf_if *, struct mbuf *,

View File

@ -133,7 +133,7 @@ void arc_storelladdr(struct ifnet *, u_int8_t);
int arc_isphds(u_int8_t);
void arc_input(struct ifnet *, struct mbuf *);
int arc_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
int arc_ioctl(struct ifnet *, u_long, caddr_t);
void arc_frag_init(struct ifnet *);

View File

@ -96,7 +96,7 @@ u_int8_t arcbroadcastaddr = 0;
*/
int
arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct arc_header *ah;
int error;

View File

@ -293,7 +293,7 @@ void atm_ifdetach(struct ifnet *);
void atm_input(struct ifnet *, struct atm_pseudohdr *,
struct mbuf *, void *);
int atm_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int,
struct mtx *, int);

View File

@ -123,7 +123,7 @@ static MALLOC_DEFINE(M_IFATM, "ifatm", "atm interface internals");
*/
int
atm_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
u_int16_t etype = 0; /* if using LLC/SNAP */
int error = 0, sz;

View File

@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
static int
ifdead_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *sa,
struct route *ro)
struct nhop_info *ni)
{
m_freem(m);

View File

@ -67,7 +67,7 @@ struct disc_softc {
};
static int discoutput(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static int discioctl(struct ifnet *, u_long, caddr_t);
static int disc_clone_create(struct if_clone *, int, caddr_t);
static void disc_clone_destroy(struct ifnet *);
@ -174,7 +174,7 @@ DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
static int
discoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
u_int32_t af;

View File

@ -89,7 +89,7 @@ struct enc_softc {
static int enc_ioctl(struct ifnet *, u_long, caddr_t);
static int enc_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
const struct sockaddr *dst, struct nhop_info *ni);
static int enc_clone_create(struct if_clone *, int, caddr_t);
static void enc_clone_destroy(struct ifnet *);
static struct if_clone *enc_cloner;
@ -190,7 +190,7 @@ DECLARE_MODULE(if_enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
static int
enc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
m_freem(m);
return (0);

View File

@ -121,7 +121,7 @@ static void ether_reassign(struct ifnet *, struct vnet *, char *);
#endif
int ether_output_full(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
const struct sockaddr *dst, struct nhop_info *ni);
int ether_output2(struct ifnet *ifp, struct mbuf *m, struct nhop_prepend *nh,
int af);
@ -151,13 +151,12 @@ update_mbuf_csumflags(struct mbuf *src, struct mbuf *dst)
int
ether_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
if (ro != NULL && (ro->ro_flags & RT_NHOP))
return (ether_output2(ifp, m, (struct nhop_prepend *)ro->ro_lle,
(ro->ro_flags >> 8) & 0xFF));
if (ni != NULL && (ni->ni_flags & RT_NHOP))
return (ether_output2(ifp, m, ni->ni_nh, ni->ni_family));
return (ether_output_full(ifp, m, dst, ro));
return (ether_output_full(ifp, m, dst, NULL));
}
/*
@ -168,7 +167,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
*/
int
ether_output_full(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
short type;
int error = 0, hdrcmplt = 0;
@ -180,11 +179,13 @@ ether_output_full(struct ifnet *ifp, struct mbuf *m,
int loop_copy = 1;
int hlen; /* link layer header length */
#if 0
if (ro != NULL) {
if (!(m->m_flags & (M_BCAST | M_MCAST)))
lle = ro->ro_lle;
rt0 = ro->ro_rt;
}
#endif
#ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error)

View File

@ -87,7 +87,7 @@ struct faith_softc {
static int faithioctl(struct ifnet *, u_long, caddr_t);
static int faithoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
#ifdef INET6
static int faithprefix(struct in6_addr *);
#endif
@ -187,7 +187,7 @@ faith_clone_destroy(ifp)
static int
faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
int isr;
u_int32_t af;
@ -195,8 +195,6 @@ faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
M_ASSERTPKTHDR(m);
if (ro != NULL)
rt = ro->ro_rt;
/* BPF writes need to be handled specially. */
if (dst->sa_family == AF_UNSPEC)
bcopy(dst->sa_data, &af, sizeof(af));

View File

@ -82,7 +82,7 @@ static const u_char fddibroadcastaddr[FDDI_ADDR_LEN] =
static int fddi_resolvemulti(struct ifnet *, struct sockaddr **,
struct sockaddr *);
static int fddi_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
static void fddi_input(struct ifnet *ifp, struct mbuf *m);
#define senderr(e) do { error = (e); goto bad; } while (0)
@ -95,7 +95,7 @@ static void fddi_input(struct ifnet *ifp, struct mbuf *m);
*/
static int
fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
u_int16_t type;
int loop_copy = 0, error = 0, hdrcmplt = 0;
@ -121,11 +121,8 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
switch (dst->sa_family) {
#ifdef INET
case AF_INET: {
struct rtentry *rt0 = NULL;
if (ro != NULL)
rt0 = ro->ro_rt;
error = arpresolve(ifp, rt0, m, dst, edst, &lle);
/* XXX: Pass is_gw flag */
error = arpresolve(ifp, NULL, m, dst, edst, &lle);
if (error)
return (error == EWOULDBLOCK ? 0 : error);
type = htons(ETHERTYPE_IP);

View File

@ -77,7 +77,7 @@ struct fw_hwaddr firewire_broadcastaddr = {
static int
firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct fw_com *fc = IFP2FWC(ifp);
int error, type;
@ -140,7 +140,8 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
* doesn't fit into the arp model.
*/
if (unicast) {
error = arpresolve(ifp, ro ? ro->ro_rt : NULL, m, dst, (u_char *) destfw, &lle);
/* XXX: Pass is_gw flag */
error = arpresolve(ifp, NULL, m, dst, (u_char *) destfw, &lle);
if (error)
return (error == EWOULDBLOCK ? 0 : error);
}

View File

@ -450,7 +450,7 @@ gif_qflush(struct ifnet *ifp __unused)
int
gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct m_tag *mtag;
uint32_t af;

View File

@ -112,7 +112,7 @@ struct etherip_header {
/* Prototypes */
void gif_input(struct mbuf *, struct ifnet *, int, uint8_t);
int gif_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
int gif_encapcheck(const struct mbuf *, int, int, void *);
#endif /* _KERNEL */

View File

@ -112,7 +112,7 @@ static void gre_qflush(struct ifnet *);
static int gre_transmit(struct ifnet *, struct mbuf *);
static int gre_ioctl(struct ifnet *, u_long, caddr_t);
static int gre_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static void gre_updatehdr(struct gre_softc *);
static int gre_set_tunnel(struct ifnet *, struct sockaddr *,
@ -785,7 +785,7 @@ gre_check_nesting(struct ifnet *ifp, struct mbuf *m)
static int
gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
uint32_t af;
int error;

View File

@ -203,7 +203,7 @@ iso88025_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
*/
int
iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
u_int16_t snap_type = 0;
int loop_copy = 0, error = 0, rif_len = 0;

View File

@ -110,7 +110,7 @@ static void lagg_linkstate(struct lagg_softc *);
static void lagg_port_state(struct ifnet *, int);
static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t);
static int lagg_port_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static void lagg_port_ifdetach(void *arg __unused, struct ifnet *);
#ifdef LAGG_PORT_STACKING
static int lagg_port_checkstacking(struct lagg_softc *);
@ -1065,14 +1065,14 @@ lagg_get_counter(struct ifnet *ifp, ift_counter cnt)
*/
static int
lagg_port_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
struct lagg_port *lp = ifp->if_lagg;
switch (dst->sa_family) {
case pseudo_AF_HDRCMPLT:
case AF_UNSPEC:
return ((*lp->lp_output)(ifp, m, dst, ro));
return ((*lp->lp_output)(ifp, m, dst, ni));
}
/* drop any other frames */

View File

@ -260,7 +260,7 @@ struct lagg_port {
/* Redirected callbacks */
int (*lp_ioctl)(struct ifnet *, u_long, caddr_t);
int (*lp_output)(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
struct lagg_counters port_counters; /* ifp counters copy */
SLIST_ENTRY(lagg_port) lp_entries;

View File

@ -54,7 +54,6 @@
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/route_internal.h>
#include <net/bpf.h>
#include <net/vnet.h>
@ -71,6 +70,8 @@
#include <netinet/ip6.h>
#endif
#include <net/rt_nhops.h>
#include <security/mac/mac_framework.h>
#ifdef TINY_LOMTU
@ -90,7 +91,7 @@
int loioctl(struct ifnet *, u_long, caddr_t);
int looutput(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
const struct sockaddr *dst, struct nhop_info *ni);
static int lo_clone_create(struct if_clone *, int, caddr_t);
static void lo_clone_destroy(struct ifnet *);
@ -200,18 +201,24 @@ DECLARE_MODULE(if_lo, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
int
looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
u_int32_t af;
struct rtentry *rt = NULL;
uint32_t af;
uint32_t nh_flags;
#ifdef MAC
int error;
#endif
M_ASSERTPKTHDR(m); /* check if we have the packet header */
if (ro != NULL)
rt = ro->ro_rt;
nh_flags = 0;
af = AF_UNSPEC;
if (ni != NULL && ni->ni_nh != NULL) {
nh_flags = ni->ni_nh->nh_flags;
af = ni->ni_family;
} else if (dst != NULL)
af = dst->sa_family;
#ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error) {
@ -220,20 +227,18 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
}
#endif
if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
if (nh_flags & (NHF_REJECT | NHF_BLACKHOLE)) {
m_freem(m);
return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
/* XXX: RTF_HOST */
return (nh_flags & NHF_BLACKHOLE ? 0 : EHOSTUNREACH);
}
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
/* BPF writes need to be handled specially. */
if (dst->sa_family == AF_UNSPEC)
if (af == AF_UNSPEC && dst != NULL)
bcopy(dst->sa_data, &af, sizeof(af));
else
af = dst->sa_family;
#if 1 /* XXX */
switch (af) {

View File

@ -120,7 +120,7 @@ static void me_qflush(struct ifnet *);
static int me_transmit(struct ifnet *, struct mbuf *);
static int me_ioctl(struct ifnet *, u_long, caddr_t);
static int me_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static int me_input(struct mbuf **, int *, int);
static int me_set_tunnel(struct ifnet *, struct sockaddr_in *,
@ -500,7 +500,7 @@ me_check_nesting(struct ifnet *ifp, struct mbuf *m)
static int
me_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
uint32_t af;
int error;

View File

@ -257,7 +257,7 @@ static const u_short interactive_ports[8] = {
int debug = ifp->if_flags & IFF_DEBUG
static int sppp_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
const struct sockaddr *dst, struct nhop_info *ni);
static void sppp_cisco_send(struct sppp *sp, int type, long par1, long par2);
static void sppp_cisco_input(struct sppp *sp, struct mbuf *m);
@ -767,7 +767,7 @@ sppp_ifstart(struct ifnet *ifp)
*/
static int
sppp_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct sppp *sp = IFP2SP(ifp);
struct ppp_header *h;

View File

@ -176,7 +176,7 @@ static int stfmodevent(module_t, int, void *);
static int stf_encapcheck(const struct mbuf *, int, int, void *);
static int stf_getsrcifa6(struct ifnet *, struct in6_addr *, struct in6_addr *);
static int stf_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
static int isrfc1918addr(struct in_addr *);
static int stf_checkaddr4(struct stf_softc *, struct in_addr *,
struct ifnet *);
@ -405,7 +405,7 @@ stf_getsrcifa6(struct ifnet *ifp, struct in6_addr *addr, struct in6_addr *mask)
static int
stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct stf_softc *sc;
const struct sockaddr_in6 *dst6;

View File

@ -126,7 +126,7 @@ static int tunifioctl(struct ifnet *, u_long, caddr_t);
static void tuninit(struct ifnet *);
static int tunmodevent(module_t, int, void *);
static int tunoutput(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *ro);
const struct sockaddr *, struct nhop_info *ni);
static void tunstart(struct ifnet *);
static int tun_clone_create(struct if_clone *, int, caddr_t);
@ -571,7 +571,7 @@ tunifioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
*/
static int
tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
struct route *ro)
struct nhop_info *ni)
{
struct tun_softc *tp = ifp->if_softc;
u_short cached_tun_flags;

View File

@ -64,7 +64,7 @@ struct socket;
struct carp_if;
struct carp_softc;
struct ifvlantrunk;
struct route; /* if_output */
struct nhop_info; /* if_output */
struct vnet;
struct ifmedia;
struct netmap_adapter;
@ -213,7 +213,7 @@ struct ifnet {
/* Various procedures of the layer2 encapsulation and drivers. */
int (*if_output) /* output routine (enqueue) */
(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct route *);
struct nhop_info *);
void (*if_input) /* input routine (from h/w driver) */
(struct ifnet *, struct mbuf *);
if_start_fn_t if_start; /* initiate output routine */

View File

@ -167,7 +167,7 @@ void iso88025_ifattach (struct ifnet *, const u_int8_t *, int);
void iso88025_ifdetach (struct ifnet *, int);
int iso88025_ioctl (struct ifnet *, u_long, caddr_t );
int iso88025_output (struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
void iso88025_input (struct ifnet *, struct mbuf *);
#endif /* _KERNEL */

View File

@ -198,6 +198,7 @@ rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt,
return (0);
}
#if 0
void
rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum)
{
@ -257,6 +258,7 @@ rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum)
}
RT_UNLOCK(ro->ro_rt);
}
#endif
extern int in6_inithead(void **head, int off);
extern int in_inithead(void **head, int off);

View File

@ -364,19 +364,10 @@ sys_setfib(struct thread *td, struct setfib_args *uap)
/*
* Packet routing routines.
*/
void
rtalloc(struct route *ro)
{
rtalloc_ign_fib(ro, 0UL, RT_DEFAULT_FIB);
}
void
rtalloc_fib(struct route *ro, u_int fibnum)
{
rtalloc_ign_fib(ro, 0UL, fibnum);
}
/*
* Legacy function for SCTP support.
*/
void
rtalloc_ign(struct route *ro, u_long ignore)
{
@ -393,21 +384,6 @@ rtalloc_ign(struct route *ro, u_long ignore)
RT_UNLOCK(ro->ro_rt);
}
void
rtalloc_ign_fib(struct route *ro, u_long ignore, u_int fibnum)
{
struct rtentry *rt;
if ((rt = ro->ro_rt) != NULL) {
if (rt->rt_ifp != NULL && rt->rt_flags & RTF_UP)
return;
RTFREE(rt);
ro->ro_rt = NULL;
}
ro->ro_rt = rtalloc1_fib(&ro->ro_dst, 1, ignore, fibnum);
if (ro->ro_rt)
RT_UNLOCK(ro->ro_rt);
}
/*
* Look up the route that matches the address given

View File

@ -44,10 +44,7 @@
*/
/*
* A route consists of a destination address, a reference
* to a routing entry, and a reference to an llentry.
* These are often held by protocols in their control
* blocks, e.g. inpcb.
* Legacy structure.
*/
struct route {
struct rtentry *ro_rt;
@ -57,10 +54,6 @@ struct route {
struct sockaddr ro_dst;
};
#define RT_CACHING_CONTEXT 0x1 /* XXX: not used anywhere */
#define RT_NORTREF 0x2 /* doesn't hold reference on ro_rt */
#define RT_NHOP 0x4
struct rt_metrics {
u_long rmx_locks; /* Kernel must leave these values alone */
u_long rmx_mtu; /* MTU for this path */
@ -109,6 +102,22 @@ VNET_DECLARE(u_int, rt_add_addr_allfibs); /* Announce interfaces to all fibs */
struct rib_head;
struct rtentry;
struct nhop_prepend;
/*
* Structure used to pass prepend information
* to if_output() routines.
*/
struct nhop_info {
struct nhop_prepend *ni_nh; /* MUST be non-NULL */
uint32_t ni_flags;
uint8_t ni_family;
uint8_t spare[3];
};
#define RT_NHOP 0x01
#define RT_NORTREF 0x2 /* doesn't hold reference on ro_rt */
#if !defined(_KERNEL) || defined(_WANT_RTENTRY)
/* This structure is kept for compatibility reasons only */
struct rtentry {
@ -316,8 +325,6 @@ int rtsock_routemsg(int, struct ifnet *ifp, int, struct rtentry *, int);
/*
* Note the following locking behavior:
*
* rtalloc_ign() and rtalloc() return ro->ro_rt unlocked
*
* rtalloc1() returns a locked rtentry
*
* rtfree() and RTFREE_LOCKED() require a locked rtentry
@ -338,7 +345,6 @@ void rt_flushifroutes(struct ifnet *ifp);
/* Thes are used by old code not yet converted to use multiple FIBS */
int rt_getifa(struct rt_addrinfo *);
void rtalloc_ign(struct route *ro, u_long ignflags);
void rtalloc(struct route *ro); /* XXX deprecated, use rtalloc_ign(ro, 0) */
struct rtentry *rtalloc1(struct sockaddr *, int, u_long);
int rtinit(struct ifaddr *, int, int);
int rtioctl(u_long, caddr_t);
@ -352,8 +358,6 @@ int rtrequest(int, struct sockaddr *,
* but this will change..
*/
int rt_getifa_fib(struct rt_addrinfo *, u_int fibnum);
void rtalloc_ign_fib(struct route *ro, u_long ignflags, u_int fibnum);
void rtalloc_fib(struct route *ro, u_int fibnum);
struct rtentry *rtalloc1_fib(struct sockaddr *, int, u_long, u_int);
int rtioctl_fib(u_long, caddr_t, u_int);
void rtredirect_fib(struct sockaddr *, struct sockaddr *,

View File

@ -369,18 +369,19 @@ fib4_sendmbuf(struct ifnet *ifp, struct mbuf *m, struct nhop_prepend *nh,
* TODO: Make special ifnet
* 'if_output_frame' handler for that.
*/
struct route_compat rc;
struct nhop_info ni;
struct ether_header *eh;
rc.ro_flags = AF_INET << 8 | RT_NHOP;
rc.ro_nh = nh;
bzero(&ni, sizeof(ni));
ni.ni_flags = RT_NHOP;
ni.ni_family = AF_INET;
ni.ni_nh = nh;
M_PREPEND(m, nh->nh_count, M_NOWAIT);
if (m == NULL)
return (ENOBUFS);
eh = mtod(m, struct ether_header *);
memcpy(eh, nh->d.data, nh->nh_count);
error = (*ifp->if_output)(ifp, m,
NULL, (struct route *)&rc);
error = (*ifp->if_output)(ifp, m, NULL, &ni);
} else {
struct sockaddr_in gw_out;
memset(&gw_out, 0, sizeof(gw_out));
@ -869,18 +870,19 @@ fib6_sendmbuf(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
* TODO: Make special ifnet
* 'if_output_frame' handler for that.
*/
struct route_compat rc;
struct nhop_info ni;
struct ether_header *eh;
rc.ro_flags = AF_INET6 << 8 | RT_NHOP;
rc.ro_nh = nh;
bzero(&ni, sizeof(ni));
ni.ni_family = AF_INET6;
ni.ni_flags = RT_NHOP;
ni.ni_nh = nh;
M_PREPEND(m, nh->nh_count, M_NOWAIT);
if (m == NULL)
return (ENOBUFS);
eh = mtod(m, struct ether_header *);
memcpy(eh, nh->d.data, nh->nh_count);
error = (*ifp->if_output)(ifp, m,
NULL, (struct route *)&rc);
error = (*ifp->if_output)(ifp, m, NULL, &ni);
} else {
/* We need to perform ND lookup */
struct sockaddr_in6 gw_out;

View File

@ -113,10 +113,6 @@ struct nhop_multi {
uint16_t nh_nhops[30]; /* Nexthop indexes */
};
/* Control plane nexthop data */
struct nhop_info {
};
/* Per-AF per-fib nhop table */
struct nhops_descr {
uint32_t nhop_size; /* Nehthop data size */
@ -220,13 +216,6 @@ struct route_info {
uint32_t scopeid; /* Desired scope id to use */
};
struct route_compat {
struct nhop_prepend *ro_nh;
void *spare0;
void *spare1;
int ro_flags;
};
int fib4_lookup_nh_ifp(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
struct nhop4_basic *pnh4);
int fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,

View File

@ -615,11 +615,13 @@ route_output(struct mbuf *m, struct socket *so, ...)
*/
if (info.rti_info[RTAX_GATEWAY] != NULL &&
info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) {
struct route gw_ro;
struct rtentry *rt;
/* XXX-ME: Is this enough? */
struct sockaddr dst;
bzero(&gw_ro, sizeof(gw_ro));
gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY];
rtalloc_ign_fib(&gw_ro, 0, fibnum);
bzero(&dst, sizeof(dst));
dst = *info.rti_info[RTAX_GATEWAY];
rt = rtalloc1_fib(&dst, 0, 0, fibnum);
/*
* A host route through the loopback interface is
* installed for each interface adddress. In pre 8.0
@ -630,14 +632,13 @@ route_output(struct mbuf *m, struct socket *so, ...)
* AF_LINK sa_family type of the rt_gateway, and the
* rt_ifp has the IFF_LOOPBACK flag set.
*/
if (gw_ro.ro_rt != NULL &&
gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK &&
gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) {
if (rt != NULL && rt->rt_gateway->sa_family == AF_LINK &&
rt->rt_ifp->if_flags & IFF_LOOPBACK) {
info.rti_flags &= ~RTF_GATEWAY;
info.rti_flags |= RTF_GWFLAG_COMPAT;
}
if (gw_ro.ro_rt != NULL)
RTFREE(gw_ro.ro_rt);
if (rt != NULL)
RTFREE_LOCKED(rt);
}
switch (rtm->rtm_type) {

View File

@ -245,11 +245,11 @@ null_transmit(struct ifnet *ifp, struct mbuf *m)
#if __FreeBSD_version >= 1000031
static int
null_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
#else
static int
null_output(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct route *ro)
struct sockaddr *dst, struct nhop_info *ni)
#endif
{
if_printf(ifp, "discard raw packet\n");

View File

@ -510,7 +510,7 @@ ieee80211_raw_output(struct ieee80211vap *vap, struct ieee80211_node *ni,
#if __FreeBSD_version >= 1000031
int
ieee80211_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni_rt)
#else
int
ieee80211_output(struct ifnet *ifp, struct mbuf *m,
@ -543,7 +543,7 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m,
* a raw 802.11 frame.
*/
if (dst->sa_family != AF_IEEE80211)
return vap->iv_output(ifp, m, dst, ro);
return vap->iv_output(ifp, m, dst, ni_rt);
#ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error)

View File

@ -98,7 +98,7 @@ int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
#if __FreeBSD_version >= 1000031
int ieee80211_output(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *ro);
const struct sockaddr *, struct nhop_info *ni);
#else
int ieee80211_output(struct ifnet *, struct mbuf *,
struct sockaddr *, struct route *ro);

View File

@ -498,7 +498,7 @@ struct ieee80211vap {
/* 802.3 output method for raw frame xmit */
#if __FreeBSD_version >= 1000031
int (*iv_output)(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
#else
int (*iv_output)(struct ifnet *, struct mbuf *,
struct sockaddr *, struct route *);

View File

@ -120,7 +120,7 @@ typedef struct ng_iface_private *priv_p;
static void ng_iface_start(struct ifnet *ifp);
static int ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
static int ng_iface_output(struct ifnet *ifp, struct mbuf *m0,
const struct sockaddr *dst, struct route *ro);
const struct sockaddr *dst, struct nhop_info *ni);
static void ng_iface_bpftap(struct ifnet *ifp,
struct mbuf *m, sa_family_t family);
static int ng_iface_send(struct ifnet *ifp, struct mbuf *m,
@ -350,7 +350,7 @@ ng_iface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
static int
ng_iface_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
struct m_tag *mtag;
uint32_t af;

View File

@ -171,7 +171,6 @@ void kmod_ipstat_dec(int statnum);
struct ip;
struct inpcb;
struct route;
struct route_info;
struct sockopt;

View File

@ -292,20 +292,6 @@ in6_rtrequest(int req, struct sockaddr *dst, struct sockaddr *gw,
return (rtrequest_fib(req, dst, gw, mask, flags, ret_nrt, fibnum));
}
void
in6_rtalloc(struct route_in6 *ro, u_int fibnum)
{
rtalloc_ign_fib((struct route *)ro, 0ul, fibnum);
}
void
in6_rtalloc_ign(struct route_in6 *ro, u_long ignflags, u_int fibnum)
{
rtalloc_ign_fib((struct route *)ro, ignflags, fibnum);
}
struct rtentry *
in6_rtalloc1(struct sockaddr *dst, int report, u_long ignflags, u_int fibnum)
{

View File

@ -836,8 +836,6 @@ void in6_rtredirect(struct sockaddr *, struct sockaddr *, struct sockaddr *,
int, struct sockaddr *, u_int);
int in6_rtrequest(int, struct sockaddr *, struct sockaddr *,
struct sockaddr *, int, struct rtentry **, u_int);
void in6_rtalloc(struct route_in6 *, u_int);
void in6_rtalloc_ign(struct route_in6 *, u_long, u_int);
struct rtentry *in6_rtalloc1(struct sockaddr *, int, u_long, u_int);
#endif /* _KERNEL */

View File

@ -2157,7 +2157,7 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
int
nd6_output_flush(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *chain,
struct sockaddr_in6 *dst, struct route *ro)
struct sockaddr_in6 *dst)
{
struct mbuf *m, *m_head;
struct ifnet *outifp;
@ -2172,7 +2172,7 @@ nd6_output_flush(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *chain,
while (m_head) {
m = m_head;
m_head = m_head->m_nextpkt;
error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, ro);
error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, NULL);
}
/*

View File

@ -235,28 +235,23 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
/* (2) check. */
if (ifa == NULL) {
struct route_in6 ro;
struct sockaddr_in6 dst;
struct rtentry *rt;
int need_proxy;
bzero(&ro, sizeof(ro));
ro.ro_dst.sin6_len = sizeof(struct sockaddr_in6);
ro.ro_dst.sin6_family = AF_INET6;
ro.ro_dst.sin6_addr = taddr6;
bzero(&dst, sizeof(dst));
dst.sin6_len = sizeof(struct sockaddr_in6);
dst.sin6_family = AF_INET6;
dst.sin6_addr = taddr6;
/* Always use the default FIB. */
#ifdef RADIX_MPATH
rtalloc_mpath_fib((struct route *)&ro, ntohl(taddr6.s6_addr32[3]),
RT_DEFAULT_FIB);
#else
in6_rtalloc(&ro, RT_DEFAULT_FIB);
#endif
need_proxy = (ro.ro_rt &&
(ro.ro_rt->rt_flags & RTF_ANNOUNCE) != 0 &&
ro.ro_rt->rt_gateway->sa_family == AF_LINK);
if (ro.ro_rt != NULL) {
rt = rtalloc1_fib((struct sockaddr *)&dst, 0, 0,RT_DEFAULT_FIB);
need_proxy = (rt && (rt->rt_flags & RTF_ANNOUNCE) != 0 &&
rt->rt_gateway->sa_family == AF_LINK);
if (rt != NULL) {
if (need_proxy)
proxydl = *SDL(ro.ro_rt->rt_gateway);
RTFREE(ro.ro_rt);
proxydl = *SDL(rt->rt_gateway);
RTFREE_LOCKED(rt);
}
if (need_proxy) {
/*
@ -951,9 +946,6 @@ nd6_na_output_fib(struct ifnet *ifp, const struct in6_addr *daddr6_0,
int icmp6len, maxlen, error;
uint32_t scopeid;
caddr_t mac = NULL;
struct route_in6 ro;
bzero(&ro, sizeof(ro));
daddr6 = *daddr6_0; /* make a local copy for modification */

View File

@ -121,7 +121,7 @@ log_dummy(struct ifnet *ifp, u_long cmd, caddr_t addr)
static int
ipfw_log_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
if (m != NULL)
FREE_PKT(m);

View File

@ -85,7 +85,7 @@ __FBSDID("$FreeBSD$");
#endif
static int pflogoutput(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static void pflogattach(int);
static int pflogioctl(struct ifnet *, u_long, caddr_t);
static void pflogstart(struct ifnet *);
@ -171,7 +171,7 @@ pflogstart(struct ifnet *ifp)
static int
pflogoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *rt)
struct nhop_info *ni)
{
m_freem(m);
return (0);

View File

@ -258,7 +258,7 @@ static void pfsync_clone_destroy(struct ifnet *);
static int pfsync_alloc_scrub_memory(struct pfsync_state_peer *,
struct pf_state_peer *);
static int pfsyncoutput(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);
const struct sockaddr *, struct nhop_info *);
static int pfsyncioctl(struct ifnet *, u_long, caddr_t);
static int pfsync_defer(struct pf_state *, struct mbuf *);
@ -1263,7 +1263,7 @@ pfsync_in_error(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count)
static int
pfsyncoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *rt)
struct nhop_info *ni)
{
m_freem(m);
return (0);

View File

@ -87,7 +87,7 @@ static void ipoib_add_one(struct ib_device *device);
static void ipoib_remove_one(struct ib_device *device);
static void ipoib_start(struct ifnet *dev);
static int ipoib_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
const struct sockaddr *dst, struct nhop_info *ni);
static int ipoib_ioctl(struct ifnet *ifp, u_long command, caddr_t data);
static void ipoib_input(struct ifnet *ifp, struct mbuf *m);
@ -1253,7 +1253,7 @@ ipoib_cleanup_module(void)
*/
static int
ipoib_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro)
const struct sockaddr *dst, struct nhop_info *ni)
{
u_char edst[INFINIBAND_ALEN];
struct llentry *lle = NULL;
@ -1262,11 +1262,13 @@ ipoib_output(struct ifnet *ifp, struct mbuf *m,
int error = 0;
short type;
#if 0
if (ro != NULL) {
if (!(m->m_flags & (M_BCAST | M_MCAST)))
lle = ro->ro_lle;
rt0 = ro->ro_rt;
}
#endif
#ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error)