Check parameter --ip --ip6 --link-local-ip in docker network connect#30807
Check parameter --ip --ip6 --link-local-ip in docker network connect#30807vdemeester merged 1 commit intomoby:masterfrom
docker network connect#30807Conversation
e8f8072 to
5a3fd12
Compare
|
I think this makes sense. |
container/container.go
Outdated
There was a problem hiding this comment.
You do not need to check the length of the list.
container/container.go
Outdated
There was a problem hiding this comment.
perhaps continue here, instead of else?
container/container.go
Outdated
There was a problem hiding this comment.
given we are parsing again later for
libnetwork.CreateOptionIpam(net.ParseIP(ipam.IPv4Address), net.ParseIP(ipam.IPv6Address), ipList, nil))
I think we should define var ip, ip6 net.IP
and change these to
if ip6 = net.ParseIP(ipam.IPv6Address); ip == nil && ipam.IPv6Address != "" {
return nil, fmt.Errorf("Error parsing parameter ip value(%s)", ipam.IPv6Address)
}
and later change to
`libnetwork.CreateOptionIpam(ip, ip6, ipList, nil))`
e780226 to
d69cb1e
Compare
container/container.go
Outdated
container/container.go
Outdated
There was a problem hiding this comment.
if you also add a llIP to the above var block, you can improve readability here dropping the else block
if llIP = net.ParseIP(ips); linkip == nil && ips != "" {
return nil, fmt.Errorf("Error....)
}
ipList = append(ipList, llIP)
}
There was a problem hiding this comment.
I have refactoring code,thank you! @aboch
d69cb1e to
40a4457
Compare
container/container.go
Outdated
There was a problem hiding this comment.
It would be nice to conform these errors to the errors docker already returns for invalid IP on docker run
As an example, I see
invalid IPv4 address: 3.3.3.333
invalid IPv6 address: 2001:db8:12345678::1
container/container.go
Outdated
There was a problem hiding this comment.
container/container.go
Outdated
There was a problem hiding this comment.
so here we should probably return
invalid link-local IP address: ....
Signed-off-by: chchliang <chen.chuanliang@zte.com.cn>
40a4457 to
b7ce6ce
Compare
|
Looks good to me. |
|
LGTM |
|
LGTM 💃 |

Signed-off-by: chchliang chen.chuanliang@zte.com.cn
- What I did

Execute
docker network connect --ip=aa network1 xxxbut successful,i think ip address invalid,should be failure. like --ip6 --link-local-ip- How I did it
To add check code in container/container.go
if epConfig != nil {
ipam := epConfig.IPAMConfig
*- How to verify it
docker network connect --ip=aa network1 59bb1359f671Error response from daemon: Invalid IPv4 address:aa