pkg: add a function to generate chain names

Adds a function to generate chain names for use in iptables and
ports all drivers to use that function. Also adds tests for the
said function.
This commit is contained in:
Abhishek Chanda
2016-03-22 17:16:59 -07:00
committed by Stefan Junker
parent bacaa11d2d
commit c33daf6706
6 changed files with 57 additions and 7 deletions

View File

@ -28,6 +28,7 @@ import (
"github.com/appc/cni/pkg/ns"
"github.com/appc/cni/pkg/skel"
"github.com/appc/cni/pkg/types"
"github.com/appc/cni/pkg/utils"
"github.com/vishvananda/netlink"
)
@ -220,7 +221,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}
if n.IPMasq {
chain := "CNI-" + n.Name
chain := utils.FormatChainName(n.Name, args.ContainerID)
if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain); err != nil {
return err
}