Hi Deniz and Thanks Dale!
"gobgp/cmd/global.go" does similar, but it might be too complex.
https://github.com/osrg/gobgp/blob/master/gobgp/cmd/global.go#L1147-L1177
The following snippet helps for you?
mpls := bgp.NewMPLSLabelStack(100)
rd := bgp.NewRouteDistinguisherTwoOctetAS(65000, 100)
// Or, if you prefer to get RD from string;
// rd, err := bgp.ParseRouteDistinguisher("65000:100")
// if err != nil {
// return nil, err
// }
nlri := bgp.NewLabeledVPNIPAddrPrefix(24, "10.0.0.0", *mpls, rd)
attrs := []bgp.PathAttributeInterface{
bgp.NewPathAttributeOrigin(0),
bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{
bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ,
[]uint32{65002, 65001}),
}),
bgp.NewPathAttributeMpReachNLRI("192.168.1.1",
[]bgp.AddrPrefixInterface{nlri}),
}
path := table.NewPath(nil, nlri, false, attrs, time.Now(), false)
Thanks,
Iwase
On 2018年04月21日 05:49, Dale Worley wrote:
On 4/20/18 9:05 AM, Deniz Aydın wrote:
I am tring to use gobgp for just announcing l3vpn-ipv4-unicast routes
stored in database, some blackhole routes for different user profiles.
Can you give me an example how can I add some l3mpls vpn path like the
one in the /GoBGP as a Go Native BGP library./
I can give you some pointers: It looks like the GoBGP constructors for route
objects closely parallel the structure of routes inside BGP. So look at
https://tools.ietf.org/html/rfc3107#page-3 for how MPLS labels are attached to
prefixes, and https://tools.ietf.org/html/rfc4364#section-4.2 for how route
distinguishers are used.
I see in github.com/osrg/gobgp/packet/bgp/bgp.go constructors like func
NewLabeledVPNIPAddrPrefix and a lot of lines containing "MPLS".
Dale
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
gobgp-devel mailing list
gobgp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gobgp-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
gobgp-devel mailing list
gobgp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gobgp-devel