libnet/d/bridge: configure store when opts missing
If the GenericData option is missing from the map, the bridge driver would skip configuration. At first glance this seems fine: the driver defaults are to not configure anything. But it also skips over initializing the persistent storage, which is configured through other option keys in the map. Fix this oversight by removing the early return. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
8a20564847
commit
e2a89b7ad1
4 changed files with 11 additions and 14 deletions
|
@ -142,7 +142,7 @@ type bridgeNetwork struct {
|
|||
}
|
||||
|
||||
type driver struct {
|
||||
config *configuration
|
||||
config configuration
|
||||
natChain *iptables.ChainInfo
|
||||
filterChain *iptables.ChainInfo
|
||||
isolationChain1 *iptables.ChainInfo
|
||||
|
@ -160,7 +160,7 @@ type driver struct {
|
|||
|
||||
// New constructs a new bridge driver
|
||||
func newDriver() *driver {
|
||||
return &driver{networks: map[string]*bridgeNetwork{}, config: &configuration{}}
|
||||
return &driver{networks: map[string]*bridgeNetwork{}}
|
||||
}
|
||||
|
||||
// Init registers a new instance of bridge driver
|
||||
|
@ -348,7 +348,7 @@ func (n *bridgeNetwork) isolateNetwork(enable bool) error {
|
|||
|
||||
func (d *driver) configure(option map[string]interface{}) error {
|
||||
var (
|
||||
config *configuration
|
||||
config configuration
|
||||
err error
|
||||
natChain *iptables.ChainInfo
|
||||
filterChain *iptables.ChainInfo
|
||||
|
@ -360,20 +360,17 @@ func (d *driver) configure(option map[string]interface{}) error {
|
|||
isolationChain2V6 *iptables.ChainInfo
|
||||
)
|
||||
|
||||
genericData, ok := option[netlabel.GenericData]
|
||||
if !ok || genericData == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch opt := genericData.(type) {
|
||||
switch opt := option[netlabel.GenericData].(type) {
|
||||
case options.Generic:
|
||||
opaqueConfig, err := options.GenerateFromModel(opt, &configuration{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config = opaqueConfig.(*configuration)
|
||||
config = *opaqueConfig.(*configuration)
|
||||
case *configuration:
|
||||
config = opt
|
||||
config = *opt
|
||||
case nil:
|
||||
// No GenericData option set. Use defaults.
|
||||
default:
|
||||
return &ErrInvalidDriverConfig{}
|
||||
}
|
||||
|
|
|
@ -1013,7 +1013,7 @@ func TestCleanupIptableRules(t *testing.T) {
|
|||
ipVersions := []iptables.IPVersion{iptables.IPv4, iptables.IPv6}
|
||||
|
||||
for _, version := range ipVersions {
|
||||
if _, _, _, _, err := setupIPChains(&configuration{EnableIPTables: true}, version); err != nil {
|
||||
if _, _, _, _, err := setupIPChains(configuration{EnableIPTables: true}, version); err != nil {
|
||||
t.Fatalf("Error setting up ip chains for %s: %v", version, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ const (
|
|||
IsolationChain2 = "DOCKER-ISOLATION-STAGE-2"
|
||||
)
|
||||
|
||||
func setupIPChains(config *configuration, version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
|
||||
func setupIPChains(config configuration, version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
|
||||
// Sanity check.
|
||||
if !config.EnableIPTables {
|
||||
return nil, nil, nil, nil, errors.New("cannot create new chains, EnableIPTable is disabled")
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestSetupIPChains(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
driverconfig := &configuration{
|
||||
driverconfig := configuration{
|
||||
EnableIPTables: true,
|
||||
}
|
||||
d := &driver{
|
||||
|
|
Loading…
Add table
Reference in a new issue