-
Notifications
You must be signed in to change notification settings - Fork 949
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
feature: modify defaut bridge mode #1424
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package bridge | |
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
|
@@ -16,13 +17,13 @@ func setupBridgeIPv4(config *networkConfiguration, i *bridgeInterface) error { | |
return fmt.Errorf("failed to retrieve bridge interface addresses: %v", err) | ||
} | ||
|
||
if !types.CompareIPNet(addrv4.IPNet, config.AddressIPv4) { | ||
if os.Getenv("SetBridgeIP") == "true" && !types.CompareIPNet(addrv4.IPNet, config.AddressIPv4) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should add something into the document, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will change it in my next job that vendor libnetwork into alibaba group. |
||
if addrv4.IPNet != nil { | ||
if err := i.nlh.AddrDel(i.Link, &addrv4); err != nil { | ||
return fmt.Errorf("failed to remove current ip address from bridge: %v", err) | ||
} | ||
} | ||
log.Debugf("Assigning address to bridge interface %s: %s", config.BridgeName, config.AddressIPv4) | ||
log.Infof("Assigning address to bridge interface %s: %s", config.BridgeName, config.AddressIPv4) | ||
if err := i.nlh.AddrAdd(i.Link, &netlink.Addr{IPNet: config.AddressIPv4}); err != nil { | ||
return &IPv4AddrAddError{IP: config.AddressIPv4, Err: err} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,33 +5,32 @@ var DefaultExecRoot = "/var/run/pouch" | |
|
||
// Config defines the network configuration. | ||
type Config struct { | ||
Type string | ||
Type string `json:"-"` | ||
|
||
MetaPath string // meta store | ||
ExecRoot string // exec root | ||
DNS []string | ||
DNSOptions []string | ||
DNSSearch []string | ||
MetaPath string `json:"meta-path"` // meta store | ||
ExecRoot string `json:"exec-root-dir"` // exec root | ||
DNS []string `json:"dns"` | ||
DNSOptions []string `json:"dns-options"` | ||
DNSSearch []string `json:"dns-search"` | ||
|
||
// bridge config | ||
BridgeConfig BridgeConfig | ||
BridgeConfig BridgeConfig `json:"bridge-config"` | ||
|
||
ActiveSandboxes map[string]interface{} | ||
ActiveSandboxes map[string]interface{} `json:"-"` | ||
} | ||
|
||
// BridgeConfig defines the bridge network configuration. | ||
type BridgeConfig struct { | ||
Name string | ||
IP string | ||
FixedCIDR string | ||
GatewayIPv4 string | ||
PreferredIP string | ||
Name string `json:"bridge-name"` | ||
IP string `json:"bip"` | ||
FixedCIDR string `json:"fixed-cidr"` | ||
GatewayIPv4 string `json:"default-gateway"` | ||
PreferredIP string `json:"preferred-ip"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is quite hard to understand this field without annotation. |
||
|
||
Mtu int | ||
ICC bool | ||
IPTables bool | ||
IPForward bool | ||
IPMasq bool | ||
UserlandProxy bool | ||
UserlandProxyPath string | ||
Mtu int `json:"mtu"` | ||
ICC bool `json:"icc"` | ||
IPTables bool `json:"iptables"` | ||
IPForward bool `json:"ipforward"` | ||
IPMasq bool `json:"ipmasq"` | ||
UserlandProxy bool `json:"userland-proxy"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this comment as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these comments is right 😄