Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of Mark / Mask in Rule? #528

Closed
antoninbas opened this issue Mar 18, 2020 · 1 comment
Closed

Change type of Mark / Mask in Rule? #528

antoninbas opened this issue Mar 18, 2020 · 1 comment

Comments

@antoninbas
Copy link

Rule is defined as follows in rule.go:

type Rule struct {
  // ...
  Mark              int
  Mask              int
  // ...
}

The default value for Mark and Mask is -1 when creating an instance of Rule with NewRule, and this translates in the corresponding attributes being omitted from the generated netlink message:

	if rule.Mark >= 0 {
		b := make([]byte, 4)
		native.PutUint32(b, uint32(rule.Mark))
		req.AddData(nl.NewRtAttr(nl.FRA_FWMARK, b))
	}
	if rule.Mask >= 0 {
		b := make([]byte, 4)
		native.PutUint32(b, uint32(rule.Mask))
		req.AddData(nl.NewRtAttr(nl.FRA_FWMASK, b))
	}

I have a package that uses github.com/vishvananda/netlink as follows:

ipRule := netlink.NewRule()
ipRule.Mark = 1 << 31
ipRule.Mask = 0xffffffff # same as using the default (-1), but writing this makes sense to be explicit
...

When I try to build this code for a 32-bit architecture (in my case arm/v7), I get errors like this:

constant 2147483648 overflows int
constant 4294967295 overflows int

Would it be possible to change the type of Mark and Mask in order to have better support for 32-bit architectures? I would suggest making these fields *int32 values.

(I have limited knowledge of ip rule but I am assuming that 1 << 31 is a legit fwmark value).

@antoninbas
Copy link
Author

Fixed by #983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant