Skip to content

Commit

Permalink
rule_linux: convert IIFNAME and OIFNAME to null terminated string
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wu Zongyong authored and vishvananda committed Sep 14, 2020
1 parent 6efc62b commit e909d4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rule_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e909d4e

Please sign in to comment.