mirror of
https://github.com/vishvananda/netlink
synced 2025-01-01 04:22:06 +00:00
rule_linux: convert IIFNAME and OIFNAME to null terminated string
Strings in GO is not null-terminated while linux is written by C and strings in C is null-terminated. Request will fail if we perform rule request with not null-terminated iifname or ofiname, with error message "no such file or directory". Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
This commit is contained in:
parent
6efc62b265
commit
e909d4e8ec
@ -142,10 +142,10 @@ func ruleHandle(rule *Rule, req *nl.NetlinkRequest) error {
|
||||
}
|
||||
}
|
||||
if rule.IifName != "" {
|
||||
req.AddData(nl.NewRtAttr(nl.FRA_IIFNAME, []byte(rule.IifName)))
|
||||
req.AddData(nl.NewRtAttr(nl.FRA_IIFNAME, []byte(rule.IifName+"\x00")))
|
||||
}
|
||||
if rule.OifName != "" {
|
||||
req.AddData(nl.NewRtAttr(nl.FRA_OIFNAME, []byte(rule.OifName)))
|
||||
req.AddData(nl.NewRtAttr(nl.FRA_OIFNAME, []byte(rule.OifName+"\x00")))
|
||||
}
|
||||
if rule.Goto >= 0 {
|
||||
msg.Type = nl.FR_ACT_GOTO
|
||||
|
Loading…
Reference in New Issue
Block a user