Skip to content

Conversation

@fesily
Copy link

@fesily fesily commented Oct 16, 2025

govpp does not utilise binapi's prompts for default member values.

// Initialize a new bond interface with the given paramters
//   - id - if non-~0, specifies a custom interface ID
//   - use_custom_mac - if set, mac_address is valid
//   - mac_address - mac addr to assign to the interface if use_custom_mac is set
//   - mode - mode, required (1=round-robin, 2=active-backup, 3=xor, 4=broadcast, 5=lacp)
//   - lb - load balance, optional (0=l2, 1=l34, 2=l23) valid for xor and lacp modes. Otherwise ignored
//   - numa_only - if numa_only is set, pkts will be transmitted by LAG members on local numa node only if have at least one, otherwise it works as usual.
//
// BondCreate defines message 'bond_create'.
// Deprecated: the message will be removed in the future versions
type BondCreate struct {
	ID           uint32                    `binapi:"u32,name=id,default=4294967295" json:"id,omitempty"`
	UseCustomMac bool                      `binapi:"bool,name=use_custom_mac" json:"use_custom_mac,omitempty"`
	MacAddress   ethernet_types.MacAddress `binapi:"mac_address,name=mac_address" json:"mac_address,omitempty"`
	Mode         BondMode                  `binapi:"bond_mode,name=mode" json:"mode,omitempty"`
	Lb           BondLbAlgo                `binapi:"bond_lb_algo,name=lb" json:"lb,omitempty"`
	NumaOnly     bool                      `binapi:"bool,name=numa_only" json:"numa_only,omitempty"`
}

func (m *BondCreate) Reset()               { *m = BondCreate{ID: 4294967295} }

@VladoLavor
Copy link
Collaborator

VladoLavor commented Oct 28, 2025

@ondrej-fabry, correct me if I'm wrong, but isn't binapi's default value tag more like an informative, and is it processed on the VPP side? I think we don't need to pre-fill them during the object creation or reset.

@fesily is there any specific scenario where you have to fill the default value by hand, otherwise the call fails, or any example where this is an issue?

@ondrej-fabry
Copy link
Member

Yes, you are correct @VladoLavor

However, that does not mean we cannot use the value to prefill. We just have not, because most of the times we build the value directly, this solution request a call to Reset that has to have the value stored in a variable. Still it might be useful and definitely makes sense for many cases. I think it's good addition. Thank you @fesily

"strconv"
"strings"

"go.fd.io/govpp/binapi/ethernet_types"
Copy link
Member

@ondrej-fabry ondrej-fabry Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not ever depend on the generate binapi. Especially not in the binapigen. Consider binapi and packages under it as example, not as code to be used inside GoVPP. Even projects using GoVPP should generate their own.

func fieldActualType(field *Field) (actual string) {
switch {
case field.TypeAlias != nil:
case field.TypeAlias != nil && field.TypeAlias.Length == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you list a case this handles/fixes?

Copy link
Member

@ondrej-fabry ondrej-fabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to regenerate existing binapi to pass a check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants