Nat-Lab / libbgp

A C++ BGP library.
https://lab.nat.moe/libbgp-doc
MIT License
17 stars 4 forks source link

[ERROR] BgpFsm::openRecv: peer BGP ID (0.0.0.11) invalid. #3

Open amb1s1 opened 3 years ago

amb1s1 commented 3 years ago

I'm trying to test libbgp with bird as a peer. When I run the peer-and-print.cc I get the following:

waiting for any client...
accept(): new client from 10.168.0.6.
ticker(): ticker started.
[DEBUG] BgpFsm::run: got message (Current state: Idle):
[DEBUG] OpenMessage {
    Version { 4 }
    MyAsn { 65001 }
    BgpId { 0.0.0.11 }
    HoldTimer { 240 }
    Capabilities {
        MpBgpCapability {
            Code { 1 }
            Afi { IPv4 }
            Safi { Unicast }
        }
        UnknowCapability {
            Code { 2 }
        }
        UnknowCapability {
            Code { 64 }
        }
        FourOctetAsnCapability {
            Code { 65 }
            MyAsn { 65001 }
        }
        UnknowCapability {
            Code { 70 }
        }
        UnknowCapability {
            Code { 71 }
        }
    }
}
[ERROR] BgpFsm::openRecv: peer BGP ID (0.0.0.11) invalid.
[DEBUG] BgpFsm::writeMessage: write (Current state: Idle):
[DEBUG] NotificationMessage {
    Error { OPEN Message Error }
    SubError { Bad Peer BGP ID }
}
waiting for the ticker thread to stop...
ticker(): ticker stopped.
closing socket & clean up...
magicnat commented 3 years ago

libbgp was expecting a valid IPv4 address as router ID; what did you configure as router ID on the bird side?

I believe non-IPv4 addresses can be use as router ID too. You can comment out the check here [1] to get rid of the error.

[1] https://github.com/Nat-Lab/libbgp/blob/master/src/bgp-fsm.cc#L344

amb1s1 commented 3 years ago

I configured as 0.0.0.11

magicnat commented 3 years ago

In this case, you can comment out the checks mentioned above, or change the router ID to something that does not start with 0, 127, 224 to 239, or 240.

I will push an update to fix the issue later. Thanks for reporting.

amb1s1 commented 3 years ago

Thanks, it is peering now.

amb1s1 commented 3 years ago

It looks like you guys are using validAddr4 for multiple functions. May I suggest to split the function to something more readable. like validRouterID and validNextHop. Thanks for your time.