- Make IFP2ENADDR() a pointer to IF_LLADDR() rather than another
copy of Ethernet address. - Change iso88025_ifattach() and fddi_ifattach() to accept MAC address as an argument, similar to ether_ifattach(), to make this work.
This commit is contained in:
parent
a0e82eba5d
commit
d09ed26fd8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152296
@ -173,7 +173,6 @@ oltr_attach(device_t dev)
|
||||
ifp->if_ioctl = oltr_ioctl;
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_NEEDSGIANT;
|
||||
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
bcopy(sc->config.macaddress, IFP2ENADDR(sc->ifp), sizeof(sc->config.macaddress));
|
||||
|
||||
/*
|
||||
* Do ifmedia setup.
|
||||
@ -203,7 +202,7 @@ oltr_attach(device_t dev)
|
||||
* Attach the interface
|
||||
*/
|
||||
|
||||
iso88025_ifattach(ifp, ISO88025_BPF_SUPPORTED);
|
||||
iso88025_ifattach(ifp, sc->config.macaddress, ISO88025_BPF_SUPPORTED);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
@ -1726,8 +1725,6 @@ an_alloc_nicmem(struct an_softc *sc, int len, int *id)
|
||||
static void
|
||||
an_setdef(struct an_softc *sc, struct an_req *areq)
|
||||
{
|
||||
struct sockaddr_dl *sdl;
|
||||
struct ifaddr *ifa;
|
||||
struct ifnet *ifp;
|
||||
struct an_ltv_genconfig *cfg;
|
||||
struct an_ltv_ssidlist_new *ssid;
|
||||
@ -1740,11 +1737,8 @@ an_setdef(struct an_softc *sc, struct an_req *areq)
|
||||
case AN_RID_GENCONFIG:
|
||||
cfg = (struct an_ltv_genconfig *)areq;
|
||||
|
||||
ifa = ifaddr_byindex(ifp->if_index);
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
bcopy((char *)&cfg->an_macaddr, IFP2ENADDR(sc->an_ifp),
|
||||
ETHER_ADDR_LEN);
|
||||
bcopy((char *)&cfg->an_macaddr, LLADDR(sdl), ETHER_ADDR_LEN);
|
||||
|
||||
bcopy((char *)cfg, (char *)&sc->an_config,
|
||||
sizeof(struct an_ltv_genconfig));
|
||||
|
@ -1239,19 +1239,14 @@ wi_setdef(sc, wreq)
|
||||
struct wi_softc *sc;
|
||||
struct wi_req *wreq;
|
||||
{
|
||||
struct sockaddr_dl *sdl;
|
||||
struct ifaddr *ifa;
|
||||
struct ifnet *ifp;
|
||||
|
||||
ifp = sc->ifp;
|
||||
|
||||
switch(wreq->wi_type) {
|
||||
case WI_RID_MAC_NODE:
|
||||
ifa = ifaddr_byindex(ifp->if_index);
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
bcopy((char *)&wreq->wi_val, (char *)&IFP2ENADDR(sc->ifp),
|
||||
ETHER_ADDR_LEN);
|
||||
bcopy((char *)&wreq->wi_val, LLADDR(sdl), ETHER_ADDR_LEN);
|
||||
break;
|
||||
case WI_RID_PORTTYPE:
|
||||
sc->wi_ptype = le16toh(wreq->wi_val[0]);
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/fddi.h>
|
||||
|
||||
@ -243,9 +242,7 @@ pdq_eisa_attach (dev)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes,
|
||||
(caddr_t) IFP2ENADDR(sc->ifp), FDDI_ADDR_LEN);
|
||||
pdq_ifattach(sc);
|
||||
pdq_ifattach(sc, sc->sc_pdq->pdq_hwaddr.lanaddr_bytes);
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
|
@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/fddi.h>
|
||||
|
||||
@ -166,9 +165,7 @@ pdq_pci_attach(device_t dev)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes,
|
||||
(caddr_t) IFP2ENADDR(sc->ifp), FDDI_ADDR_LEN);
|
||||
pdq_ifattach(sc);
|
||||
pdq_ifattach(sc, sc->sc_pdq->pdq_hwaddr.lanaddr_bytes);
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
|
@ -260,7 +260,7 @@ pdq_state_t pdq_stop (pdq_t *pdq);
|
||||
* OS dependent functions provided by
|
||||
* pdq_ifsubr.c or pdq.c to the bus front ends
|
||||
*/
|
||||
void pdq_ifattach (pdq_softc_t *);
|
||||
void pdq_ifattach (pdq_softc_t *, const pdq_uint8_t *);
|
||||
void pdq_ifdetach (pdq_softc_t *);
|
||||
void pdq_free (device_t);
|
||||
int pdq_interrupt (pdq_t *pdq);
|
||||
|
@ -410,7 +410,7 @@ pdq_ifioctl(
|
||||
#endif
|
||||
|
||||
void
|
||||
pdq_ifattach(pdq_softc_t *sc)
|
||||
pdq_ifattach(pdq_softc_t *sc, const pdq_uint8_t *llc)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
@ -441,7 +441,7 @@ pdq_ifattach(pdq_softc_t *sc)
|
||||
}
|
||||
#endif
|
||||
|
||||
fddi_ifattach(ifp, FDDI_BPF_SUPPORTED);
|
||||
fddi_ifattach(ifp, llc, FDDI_BPF_SUPPORTED);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -97,7 +97,7 @@ struct fddi_header {
|
||||
#define FDDI_BPF_UNSUPPORTED 0
|
||||
#define FDDI_BPF_SUPPORTED 1
|
||||
|
||||
void fddi_ifattach(struct ifnet *, int);
|
||||
void fddi_ifattach(struct ifnet *, const u_int8_t *, int);
|
||||
void fddi_ifdetach(struct ifnet *, int);
|
||||
int fddi_ioctl(struct ifnet *, int, caddr_t);
|
||||
|
||||
|
10
sys/net/if.c
10
sys/net/if.c
@ -59,7 +59,6 @@
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_clone.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
@ -2101,19 +2100,12 @@ if_setlladdr(struct ifnet *ifp, const u_char *lladdr, int len)
|
||||
if (len != sdl->sdl_alen) /* don't allow length to change */
|
||||
return (EINVAL);
|
||||
switch (ifp->if_type) {
|
||||
case IFT_ETHER: /* these types use struct arpcom */
|
||||
case IFT_ETHER:
|
||||
case IFT_FDDI:
|
||||
case IFT_XETHER:
|
||||
case IFT_ISO88025:
|
||||
case IFT_L2VLAN:
|
||||
case IFT_BRIDGE:
|
||||
bcopy(lladdr, IFP2ENADDR(ifp), len);
|
||||
/*
|
||||
* XXX We also need to store the lladdr in LLADDR(sdl),
|
||||
* which is done below. This is a pain because we must
|
||||
* remember to keep the info in sync.
|
||||
*/
|
||||
/* FALLTHROUGH */
|
||||
case IFT_ARCNET:
|
||||
bcopy(lladdr, LLADDR(sdl), len);
|
||||
break;
|
||||
|
@ -103,7 +103,7 @@ struct arpreq {
|
||||
*/
|
||||
struct arpcom {
|
||||
struct ifnet *ac_ifp; /* network-visible interface */
|
||||
u_char _ac_enaddr[6]; /* ethernet hardware address */
|
||||
u_char *_ac_enaddr; /* ethernet hardware address */
|
||||
void *ac_netgraph; /* ng_ether(4) netgraph node info */
|
||||
};
|
||||
#define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com))
|
||||
|
@ -846,7 +846,7 @@ ether_sprintf(const u_char *ap)
|
||||
* Perform common duties while attaching to interface list
|
||||
*/
|
||||
void
|
||||
ether_ifattach(struct ifnet *ifp, const u_int8_t *llc)
|
||||
ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
|
||||
{
|
||||
int i;
|
||||
struct ifaddr *ifa;
|
||||
@ -868,13 +868,8 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *llc)
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
sdl->sdl_type = IFT_ETHER;
|
||||
sdl->sdl_alen = ifp->if_addrlen;
|
||||
bcopy(llc, LLADDR(sdl), ifp->if_addrlen);
|
||||
/*
|
||||
* XXX: This doesn't belong here; we do it until
|
||||
* XXX: all drivers are cleaned up
|
||||
*/
|
||||
if (llc != IFP2ENADDR(ifp))
|
||||
bcopy(llc, IFP2ENADDR(ifp), ifp->if_addrlen);
|
||||
bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
|
||||
IFP2ENADDR(ifp) = LLADDR(sdl);
|
||||
|
||||
bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
|
||||
if (ng_ether_attach_p != NULL)
|
||||
@ -882,10 +877,10 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *llc)
|
||||
|
||||
/* Announce Ethernet MAC address if non-zero. */
|
||||
for (i = 0; i < ifp->if_addrlen; i++)
|
||||
if (llc[i] != 0)
|
||||
if (lla[i] != 0)
|
||||
break;
|
||||
if (i != ifp->if_addrlen)
|
||||
if_printf(ifp, "Ethernet address: %6D\n", llc, ":");
|
||||
if_printf(ifp, "Ethernet address: %6D\n", lla, ":");
|
||||
if (debug_mpsafenet && (ifp->if_flags & IFF_NEEDSGIANT) != 0)
|
||||
if_printf(ifp, "if_start running deferred for Giant\n");
|
||||
}
|
||||
|
@ -556,8 +556,9 @@ fddi_input(ifp, m)
|
||||
* Perform common duties while attaching to interface list
|
||||
*/
|
||||
void
|
||||
fddi_ifattach(ifp, bpf)
|
||||
fddi_ifattach(ifp, lla, bpf)
|
||||
struct ifnet *ifp;
|
||||
const u_int8_t *lla;
|
||||
int bpf;
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
@ -587,7 +588,8 @@ fddi_ifattach(ifp, bpf)
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
sdl->sdl_type = IFT_FDDI;
|
||||
sdl->sdl_alen = ifp->if_addrlen;
|
||||
bcopy(IFP2ENADDR(ifp), LLADDR(sdl), ifp->if_addrlen);
|
||||
bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
|
||||
IFP2ENADDR(ifp) = LLADDR(sdl);
|
||||
|
||||
if (bpf)
|
||||
bpfattach(ifp, DLT_FDDI, FDDI_HDR_LEN);
|
||||
|
@ -91,7 +91,7 @@ static int iso88025_resolvemulti (struct ifnet *, struct sockaddr **,
|
||||
* Perform common duties while attaching to interface list
|
||||
*/
|
||||
void
|
||||
iso88025_ifattach(struct ifnet *ifp, int bpf)
|
||||
iso88025_ifattach(struct ifnet *ifp, const u_int8_t *lla, int bpf)
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
struct sockaddr_dl *sdl;
|
||||
@ -123,7 +123,8 @@ iso88025_ifattach(struct ifnet *ifp, int bpf)
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
sdl->sdl_type = IFT_ISO88025;
|
||||
sdl->sdl_alen = ifp->if_addrlen;
|
||||
bcopy(IFP2ENADDR(ifp), LLADDR(sdl), ifp->if_addrlen);
|
||||
bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
|
||||
IFP2ENADDR(ifp) = LLADDR(sdl);
|
||||
|
||||
if (bpf)
|
||||
bpfattach(ifp, DLT_IEEE802, ISO88025_HDR_LEN);
|
||||
|
@ -663,9 +663,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
|
||||
static int
|
||||
vlan_config(struct ifvlan *ifv, struct ifnet *p)
|
||||
{
|
||||
struct ifaddr *ifa1, *ifa2;
|
||||
struct ifnet *ifp;
|
||||
struct sockaddr_dl *sdl1, *sdl2;
|
||||
|
||||
VLAN_LOCK_ASSERT();
|
||||
|
||||
@ -741,14 +739,7 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p)
|
||||
* Set up our ``Ethernet address'' to reflect the underlying
|
||||
* physical interface's.
|
||||
*/
|
||||
ifa1 = ifaddr_byindex(ifp->if_index);
|
||||
ifa2 = ifaddr_byindex(p->if_index);
|
||||
sdl1 = (struct sockaddr_dl *)ifa1->ifa_addr;
|
||||
sdl2 = (struct sockaddr_dl *)ifa2->ifa_addr;
|
||||
sdl1->sdl_type = IFT_ETHER;
|
||||
sdl1->sdl_alen = ETHER_ADDR_LEN;
|
||||
bcopy(LLADDR(sdl2), LLADDR(sdl1), ETHER_ADDR_LEN);
|
||||
bcopy(LLADDR(sdl2), IFP2ENADDR(ifp), ETHER_ADDR_LEN);
|
||||
bcopy(IF_LLADDR(p), IF_LLADDR(ifp), ETHER_ADDR_LEN);
|
||||
|
||||
/*
|
||||
* Configure multicast addresses that may already be
|
||||
@ -762,8 +753,6 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p)
|
||||
static int
|
||||
vlan_unconfig(struct ifnet *ifp)
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
struct sockaddr_dl *sdl;
|
||||
struct vlan_mc_entry *mc;
|
||||
struct ifvlan *ifv;
|
||||
struct ifnet *p;
|
||||
@ -812,12 +801,7 @@ vlan_unconfig(struct ifnet *ifp)
|
||||
ifv->ifv_ifp->if_link_state = LINK_STATE_UNKNOWN;
|
||||
|
||||
/* Clear our MAC address. */
|
||||
ifa = ifaddr_byindex(ifv->ifv_ifp->if_index);
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
sdl->sdl_type = IFT_ETHER;
|
||||
sdl->sdl_alen = ETHER_ADDR_LEN;
|
||||
bzero(LLADDR(sdl), ETHER_ADDR_LEN);
|
||||
bzero(IFP2ENADDR(ifv->ifv_ifp), ETHER_ADDR_LEN);
|
||||
bzero(IF_LLADDR(ifv->ifv_ifp), ETHER_ADDR_LEN);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ struct iso88025_addr {
|
||||
#define ISO88025_BPF_UNSUPPORTED 0
|
||||
#define ISO88025_BPF_SUPPORTED 1
|
||||
|
||||
void iso88025_ifattach (struct ifnet *, int);
|
||||
void iso88025_ifattach (struct ifnet *, const u_int8_t *, int);
|
||||
void iso88025_ifdetach (struct ifnet *, int);
|
||||
int iso88025_ioctl (struct ifnet *, int , caddr_t );
|
||||
int iso88025_output (struct ifnet *, struct mbuf *, struct sockaddr *,
|
||||
|
@ -57,7 +57,7 @@
|
||||
* is created, otherwise 1.
|
||||
*/
|
||||
#undef __FreeBSD_version
|
||||
#define __FreeBSD_version 700004 /* Master, propagated to newvers */
|
||||
#define __FreeBSD_version 700005 /* Master, propagated to newvers */
|
||||
|
||||
#ifndef LOCORE
|
||||
#include <sys/types.h>
|
||||
|
Loading…
Reference in New Issue
Block a user