Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/route_ifaddrs.c
Show All 26 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* @(#)route.c 8.3.1.1 (Berkeley) 2/23/95 | * @(#)route.c 8.3.1.1 (Berkeley) 2/23/95 | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include "opt_mpath.h" | |||||
#include "opt_route.h" | #include "opt_route.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/syslog.h> | #include <sys/syslog.h> | ||||
Show All 15 Lines | |||||
/* | /* | ||||
* Control interface address fib propagation. | * Control interface address fib propagation. | ||||
* By default, interface address routes are added to the fib of the interface. | * By default, interface address routes are added to the fib of the interface. | ||||
* Once set to non-zero, adds interface address route to all fibs. | * Once set to non-zero, adds interface address route to all fibs. | ||||
*/ | */ | ||||
VNET_DEFINE(u_int, rt_add_addr_allfibs) = 0; | VNET_DEFINE(u_int, rt_add_addr_allfibs) = 0; | ||||
SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN | CTLFLAG_VNET, | SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN | CTLFLAG_VNET, | ||||
&VNET_NAME(rt_add_addr_allfibs), 0, ""); | &VNET_NAME(rt_add_addr_allfibs), 0, ""); | ||||
static int | |||||
handle_change(struct rt_addrinfo *info, int fibnum) | |||||
{ | |||||
struct epoch_tracker et; | |||||
struct rib_cmd_info rc; | |||||
NET_EPOCH_ENTER(et); | |||||
error = rib_action(fibnum, cmd, &info, &rc); | |||||
if (error == 0) { | |||||
/* | |||||
* notify any listening routing agents of the change | |||||
*/ | |||||
KASSERT(rc.rc_rt != NULL, ("F")); | |||||
/* TODO: interface routes/aliases */ | |||||
rt_newaddrmsg_fib(cmd, ifa, rc.rc_rt, fibnum); | |||||
} | |||||
NET_EPOCH_EXIT(et); | |||||
return (error); | |||||
} | |||||
static int | |||||
rtinit2(struct ifaddr *ifa, int cmd, int flags, int fibnum) | |||||
{ | |||||
RIB_RLOCK_TRACKER; | |||||
struct epoch_tracker et; | |||||
struct sockaddr *dst; | |||||
struct sockaddr *netmask; | |||||
struct rt_addrinfo info; | |||||
struct sockaddr_dl_short sdl; | |||||
struct rib_head *rnh; | |||||
if (flags & RTF_HOST) { | |||||
dst = ifa->ifa_dstaddr; | |||||
netmask = NULL; | |||||
} else { | |||||
dst = (struct sockaddr *)&ss; | |||||
netmask = ifa->ifa_netmask; | |||||
rt_maskedcopy(ifa->ifa_addr, dst, netmask); | |||||
} | |||||
/* Gateway for the interface routes is always AF_LINK with interface index */ | |||||
bzero(&sdl, sizeof(struct sockaddr_dl_short)); | |||||
sdl.sdl_family = AF_LINK; | |||||
sdl.sdl_len = sizeof(struct sockaddr_dl_short); | |||||
sdl.sdl_type = ifa->ifa_ifp->if_type; | |||||
sdl.sdl_index = ifa->ifa_ifp->if_index; | |||||
/* Setup actual request */ | |||||
bzero(&info, sizeof(info)); | |||||
info.rti_ifa = ifa; | |||||
info.rti_flags = flags | (ifa->ifa_flags & ~IFA_RTSELF) | RTF_PINNED; | |||||
info.rti_info[RTAX_DST] = dst; | |||||
info.rti_info[RTAX_NETMASK] = netmask; | |||||
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sdl; | |||||
} | |||||
/* | /* | ||||
* Set up a routing table entry, normally | * Set up a routing table entry, normally | ||||
* for an interface. | * for an interface. | ||||
*/ | */ | ||||
static inline int | static inline int | ||||
rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum) | rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |