osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.64k stars 693 forks source link

Local address ignored when calling AddPeer through API #1816

Closed ecbaldwin closed 6 years ago

ecbaldwin commented 6 years ago

I tried adding a peer through the API with a specified local address because the peer router is expected a connected from this hosts loopback address. When I configure this peer in the config file, it works as expected.

[[neighbors]]
    [neighbors.config]
        neighbor-address = "10.112.97.1"
        peer-as = 4206900001
    [neighbors.transport.config]
        local-address = "10.112.128.1"
    [neighbors.ebgp-multihop.config]
        enabled = true
        multihop-ttl = 16
    [neighbors.graceful-restart.config]
        enabled = true
        notification-enabled = true
        long-lived-enabled = true
        restart-time = 4095
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
        afi-safi-name = "ipv4-unicast"
        [neighbors.afi-safis.mp-graceful-restart.config]
            enabled = true
        [neighbors.afi-safis.long-lived-graceful-restart.config]
            enabled = true
            restart-time = 43200

However, when I configure it from python using the API with what should be the equivalent configuration, the local address part is ignored and the source address because whatever the source address is configured on the interface in Linux.

    stub.AddPeer(gobgp_pb2.AddPeerRequest(peer=gobgp_pb2.Peer(
        conf=gobgp_pb2.PeerConf(
            neighbor_address="10.112.97.1",
            peer_as=4206900001,
            local_address="10.112.128.1"),
            ebgp_multihop=gobgp_pb2.EbgpMultihop(
                enabled=True,
                multihop_ttl=32),
            graceful_restart=gobgp_pb2.GracefulRestart(
                enabled=True,
                notification_enabled=True,
                longlived_enabled=True,
                restart_time=120),
            afi_safis=[gobgp_pb2.AfiSafi(
                config=gobgp_pb2.AfiSafiConfig(
                    family=gobgp_pb2.IPv4,
                    enabled=True),
                mp_graceful_restart=gobgp_pb2.MpGracefulRestart(
                    config=gobgp_pb2.MpGracefulRestartConfig(
                        enabled=True)),
                long_lived_graceful_restart=gobgp_pb2.LongLivedGracefulRestart(
                    config=gobgp_pb2.LongLivedGracefulRestartConfig(
                        enabled=True,
                        restart_time=(12*3600))))])))
ecbaldwin commented 6 years ago

This is with 008c961ecd943739c5db63fcd931904804a45aa5.

fujita commented 6 years ago

Can you try local_address Peer.Transport?

ecbaldwin commented 6 years ago

I did have some issues with my indentation which might have been confusing. I apologize for that. I tried local_address in Peer.Transport as you suggested and it worked. Thanks.

I guess the issue was that I was not able to see past the local_address field in PeerConf. Can we at least remove that if it is not used? I'm going to leave this issue open to resolve this.

fujita commented 6 years ago

I'll remove that field with other unused fields in the protobuf file once I finish the family change.