Routing: Linux Implementation

Routing options can be classified into two categories:

• The ones that are always supported, and that only need to be enabled or configured
by the user, such as via /proc

• The ones whose support may be added or removed by recompiling the kernel
with the right options. The CONFIG_WAN_ROUTER option and the options under the
CONFIG_IP_ROUTE_MULTIPATH_CACHED menu can be compiled as modules; the others
must be compiled into the main kernel.

The kernel defines an rt_scope_t enum that lists possible scopes in include/linux/
rtnetlink.h. Its values range from 0 to 255, where 0 (RT_SCOPE_UNIVERSE) represents

the broadest scope.

The scope of a route is saved in the fa_scope field of the fib_alias data structure.Here are the main scopes used by the IPv4 routing code,
in order of increasing scope:

RT_SCOPE_NOWHERE
This value,  is treated by the code as illegal.
The literal meaning is that the route does not lead anywhere, which basically
means there is no route to the destination.

RT_SCOPE_HOST
Examples of these routes are the ones created automatically when configuring IP
addresses on the local interfaces (see the section “Adding an IP address”).
RT_SCOPE_LINK
This includes routes to the local network (as defined by the netmask) and to the
subnet broadcast addresses derived from locally configured addresses (see the
section “Adding an IP address”).
RT_SCOPE_UNIVERSE
This is used for all routes that lead to remote destinations not directly connected
(i.e., the ones that require a next-hop gateway).

Remember that for
every route, nh_scope is the next hop’s scope and nh_gw is the next hop’s IP address

Secondary IPv4 addresses are tagged with the IFA_F_SECONDARY flag in their in_ifaddr
data structures

At the highest level, routes are organized into different hash tables based on the
lengths of their netmasks.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值