From bb562572bc24b8b98a55327c582991ce2b9c20af Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Fri, 16 Jun 2017 09:40:12 +0900 Subject: server: Enable to configure static TTL for BGP packets Like "ttl" configuration of Junos OS, this patch enables to set static TTL value for outgoing BGP packets. Signed-off-by: IWASE Yusuke --- docs/sources/configuration.md | 1 + server/fsm.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/sources/configuration.md b/docs/sources/configuration.md index e308b3ab..71e654fb 100644 --- a/docs/sources/configuration.md +++ b/docs/sources/configuration.md @@ -65,6 +65,7 @@ passive-mode = true local-address = "192.168.10.1" remote-port = 2016 + ttl = 64 # default value on Linux [neighbors.ebgp-multihop.config] enabled = true multihop-ttl = 100 diff --git a/server/fsm.go b/server/fsm.go index 4f19bc39..afd04b3e 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -493,10 +493,15 @@ func (h *FSMHandler) active() (bgp.FSMState, FsmStateReason) { ttl = 255 ttlMin = int(fsm.pConf.TtlSecurity.Config.TtlMin) } else if fsm.pConf.Config.PeerAs != 0 && fsm.pConf.Config.PeerType == config.PEER_TYPE_EXTERNAL { - ttl = 1 if fsm.pConf.EbgpMultihop.Config.Enabled { ttl = int(fsm.pConf.EbgpMultihop.Config.MultihopTtl) + } else if fsm.pConf.Transport.Config.Ttl != 0 { + ttl = int(fsm.pConf.Transport.Config.Ttl) + } else { + ttl = 1 } + } else if fsm.pConf.Transport.Config.Ttl != 0 { + ttl = int(fsm.pConf.Transport.Config.Ttl) } if ttl != 0 { if err := SetTcpTTLSockopts(conn.(*net.TCPConn), ttl); err != nil { -- cgit v1.2.3