Hi Pim,

Thanks for the report — I had a look at the lb code and found 2 more issues on 
top of yours:
- encap byte order on input: vl_api_lb_encap_type_t is a u32 packed big-endian 
by PAPI. In lb_add_del_vip and lb_add_del_vip_v2, mp->encap is compared 
directly against LB_API_ENCAP_TYPE_* without conversion. GRE4=0 works by 
coincidence, but GRE6, L3DSR, NAT4 and NAT6 all get the wrong VIP type 
silently. Needs clib_net_to_host_u32(mp->encap) before the comparison.
- port byte order in lb_as_dump filter: mp->port is compared directly to 
vip->port (host byte order), silently matching nothing for per-port VIPs. Needs 
ntohs().

Jerome

De : [email protected] <[email protected]> de la part de Pim van Pelt via 
lists.fd.io <[email protected]>
Date : mardi, 7 avril 2026 à 09:43
À : [email protected] <[email protected]>
Objet : [vpp-dev] Maglev API bugfixes

Hoi,

I've found a few issues with the loadbalancer plugin - notably in the binary 
API. See https://gerrit.fd.io/r/c/vpp/+/45428

1) When creating two VIPs using the following Python snippet::
api_reply = vpp.api.lb_add_del_vip(pfx="10.0.0.2/32", port=80)
print(api_reply)
api_reply = vpp.api.lb_add_del_vip(pfx="2001:db8::2/128", port=80)
print(api_reply)
api_reply = vpp.api.lb_vip_dump()
print(api_reply)

The API call returns an invalid VIP object:
lb_add_del_vip_reply(_0=340, context=3, retval=0)
lb_add_del_vip_reply(_0=340, context=4, retval=0)
[lb_vip_details(_0=348, context=5, 
vip=vl_api_lb_vip_t(pfx=IPv4Interface('0.0.0.0/32'), 
protocol=<vl_api_ip_proto_t.IP_API_PROTO_HOPOPT: 0>, port=80), 
encap=<vl_api_lb_encap_type_t.LB_API_ENCAP_TYPE_GRE6: 1>, 
dscp=<vl_api_ip_dscp_t.IP_API_DSCP_CS0: 0>, 
srv_type=<vl_api_lb_srv_type_t.LB_API_SRV_TYPE_CLUSTERIP: 0>, target_port=0, 
flow_table_length=0), lb_vip_details(_0=348, context=5, 
vip=vl_api_lb_vip_t(pfx=IPv6Interface('2001:db8::2/128'), 
protocol=<vl_api_ip_proto_t.IP_API_PROTO_HOPOPT: 0>, port=80), 
encap=<vl_api_lb_encap_type_t.LB_API_ENCAP_TYPE_GRE6: 1>, 
dscp=<vl_api_ip_dscp_t.IP_API_DSCP_CS0: 0>, 
srv_type=<vl_api_lb_srv_type_t.LB_API_SRV_TYPE_CLUSTERIP: 0>, target_port=0, 
flow_table_length=0)]

2) When creating a VIP on the CLI with a specific encap, the lb_vip_dump() 
returns the raw value of htonl(vip->type) even though there is an API enum 
lb_encap_type.

3) When deleting an AS or VIP, the garbage collector only runs on subsequent 
CLI input, so cleanups will never occur when using only the binary API

4) You can set LB global config (like ip4-src-address and ip6-src-address) via 
lb_conf() API, but there is no lb_conf_get() API.

5) CLI 'show lb vips' without 'verbose' returns nothing due to a parsing error.

Please take a look.

groet,
Pim

--
Pim van Pelt <[email protected]><mailto:[email protected]>
PBVP1-RIPE https://ipng.ch/
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#26947): https://lists.fd.io/g/vpp-dev/message/26947
Mute This Topic: https://lists.fd.io/mt/118704457/21656
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/leave/14379924/21656/631435203/xyzzy 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to