BCP功能简介及调试方法
1. BCP简介
BCP是最近研究的一个网络协议,主要是基于PPP链路,能够把双方子网的网络桥接。
BCP全称: Point-to-Point Protocol (PPP) Bridging Control Protocol (BCP)
简介:
The Point-to-Point Protocol (PPP) provides a standard method for
transporting multi-protocol datagrams over point-to-point links. PPP
defines an extensible Link Control Protocol (LCP) and proposes a
family of Network Control Protocols (NCP) for establishing and
configuring different network-layer protocols.
This document defines the NCP for establishing and configuring Remote
Bridging for PPP links.
This document obsoletes RFC 2878, which was based on the IEEE
802.1D-1993 MAC Bridge. This document extends that specification by
improving support for bridge control packets.
2. BCP网络拓扑图
3. BCP协议分析
详细参考RFC3518文档(前身有RFC1638,RFC2878)
下载地址:链接: https://pan.baidu.com/s/1zJmiwen9fQBpDMRQrV7T0w 提取码: 2gkc
4. BCP功能增加指南
目前,支持此功能的设备主要有Cisco,Mikrotik(RouterOS系统)等。
4.1 自己折腾
详细参考如下patch:
参考连接:
1)内核patch:https://lists.linuxfoundation.org/pipermail/bridge/2004-February/003788.html
2)pppd patch:https://lists.linuxfoundation.org/pipermail/bridge/2004-February/003787.html
附件下载地址:链接: https://pan.baidu.com/s/1o0N7i-r-rUnQTQN1BCf0_Q 提取码: 464f
从此patch文件可以得知,主要修改linux kernel和ppp代码,增加bridge的支持。
虽然patch支持的版本比较低(ppp 版本V2.4.1, 内核版本V2.4.1),但是还是非常具有参考价值的,从无到有的过程,对我帮助很大。
我在调试的过程中(适配内核版本3.3.x,ppp版本2.4.7),发现ppp建立bcp0网卡的时候,一直会导致内核cpu0,系统奔溃。经过柱栋
修改内核的代码后,内核的错误没有了。但是创建bcp0网卡一直失败。由于本人对内核不熟悉,柱栋出差时间比较少,所以一直没有进展。应市场需要,领导确定让第三方公司帮忙。
4.2 第三方公司调试说明
他们的参考文档,与我上面发的一样。都是来自Dane作者的patch,只是适配了我们现在的内核版本3.3.x/3.4.x及ppp版本2.4.7,另外修改了xl2tpd-1.3.14的部分功能。
4.2.1 xl2tpd修改说明
适配xl2tpd版本:1.3.14
xl2tp: add "disable ip" config option
Add "disable ip" config file parameter in lac section to have xl2tpd
not tear down its session if no IP address is set. This is required if
pppd is used with IPCP disabled (noip).
---
xl2tp-1.3.14/control.c | 30 ++++++++++++++++++------------
xl2tp-1.3.14/file.c | 18 ++++++++++++++++++
xl2tp-1.3.14/file.h | 1 +
3 files changed, 37 insertions(+), 12 deletions(-)
4.2.2 ppp修改说明
适配ppp版本:2.4.7
ppp: add bcp network protocol
Import patch from
https://lists.linuxfoundation.org/pipermail/bridge/2005-May/004523.html
of work begun in 2004 which was never completed.
Reverse logic of bridge option such that BCP is enabled only when
bridge option is specified.
Have bridge_mac option accept a 3-byte OUI with the remaining 3-bytes
of a MAC address then randomly generated.
Add support for BCP 802-Tagged-Frames negotiation (rfc2878).
Add bridge_vlan option to control 802-Tagged-Frames BCP parameter.
Modify all network protocols to tear down ppp connection of sifnpmode
returns an error.
Add BCP printer for BridgeControlPacketIndicator (rfc3518). This is
not supported by the Linux kernel so is not negotiated by
pppd. However, it is useful to log it in pppd debug output.
Fetch and log link stats on BCP protocol down, consistent with other
network protocols.
pppd supports some additional options:-
bridge - enables BCP. Default: BCP is not enabled.
bridge_mac mac|oui - set the MAC of the local bcpN interface. Takes a
MAC address or MAC OUI arg.
xx:xx:xx:xx:xx:xx (MAC address)
xx:xx:xx (OUI)
If parameter is xx:xx:xx, a MAC address is
autogenerated using the OUI and 3 random bytes.
Bit 0 of the first byte is the MAC Multicast bit
so must never be set.
Bit 1 of the first byte if the MAC Local bit
indicating a locally generated MAC. This is
always set if the arg is xx:xx:xx.
bridge_vlan - enables 802-Tagged-Frames BCP parameter. Default: off.
If bridge option is specified without bridge_mac, pppd requires that
the peer assign it a MAC during BCP negotiation. When testing this,
we found no current ppp implementation that supports this. Therefore,
when bridge option is specified, always also include bridge_mac.
If VLAN tagged frames are to be carried over the PPP bridge link, add
the bridge_vlan option. Note that bridge_vlan tells the peer only
that we may be sending VLAN frames and we will accept VLAN frames, it
does not tell the peer which VLAN tags will be used. Configuration of
VLANs on the bcpN interface would be done using commands in
/etc/ppp/eth-up or by a VLAN protocol such as GVRP. If BCP peers do
not agree to enable 802-Tagged-Frames, no VLAN tagged frame should be
transmitted or received on the bcpN interface.
When bcp interfaces are created or destroyed, pppd runs scripts
/etc/ppp/eth-up and /etc/ppp/eth-down if they exist and are
executable. The scripts are called with the following arguments:
eth-up - $1 - interface name, e.g. bcp0
$2 - "vlan" or "novlan", depending on whether 802-Tagged-Frames was
negotiated.
eth-down - $1 - interface name, e.g. bcp0
---
ppp-2.4.7/include/linux/ppp_defs.h | 3 +
ppp-2.4.7/include/net/ppp_defs.h | 3 +
ppp-2.4.7/pppd/Makefile.linux | 6 +-
ppp-2.4.7/pppd/bcp.c | 1864 ++++++++++++++++++++++++++++++++++++
ppp-2.4.7/pppd/bcp.h | 76 ++
ppp-2.4.7/pppd/ipcp.c | 15 +-
ppp-2.4.7/pppd/ipv6cp.c | 15 +-
ppp-2.4.7/pppd/ipxcp.c | 7 +
ppp-2.4.7/pppd/main.c |