mirror of
https://github.com/devplayer0/docker-net-dhcp
synced 2024-11-16 21:28:01 +00:00
Broken routes
This commit is contained in:
parent
b5844947e4
commit
04f93b16cc
@ -181,17 +181,42 @@ def delete_endpoint():
|
|||||||
@app.route('/NetworkDriver.Join', methods=['POST'])
|
@app.route('/NetworkDriver.Join', methods=['POST'])
|
||||||
def join():
|
def join():
|
||||||
req = request.get_json(force=True)
|
req = request.get_json(force=True)
|
||||||
logger.info(req)
|
|
||||||
|
|
||||||
bridge = net_bridge(req['NetworkID'])
|
bridge = net_bridge(req['NetworkID'])
|
||||||
_if_host, if_container = veth_pair(req['EndpointID'])
|
_if_host, if_container = veth_pair(req['EndpointID'])
|
||||||
|
|
||||||
return jsonify({
|
res = {
|
||||||
'InterfaceName': {
|
'InterfaceName': {
|
||||||
'SrcName': if_container,
|
'SrcName': if_container,
|
||||||
'DstPrefix': bridge.ifname
|
'DstPrefix': bridge.ifname
|
||||||
|
},
|
||||||
|
'StaticRoutes': []
|
||||||
}
|
}
|
||||||
|
# TODO: IPv6 routes
|
||||||
|
nonlink = []
|
||||||
|
for route in ipdb.routes:
|
||||||
|
logging.info(route)
|
||||||
|
if route.oif != bridge.index:
|
||||||
|
continue
|
||||||
|
if route.dst == 'default' and 'Gateway' not in res:
|
||||||
|
res['Gateway'] = route.gateway
|
||||||
|
elif route.gateway:
|
||||||
|
nonlink.append({
|
||||||
|
'Destination': route.dst,
|
||||||
|
'RouteType': 0,
|
||||||
|
'NextHop': route.gateway
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
# on-link route
|
||||||
|
res['StaticRoutes'].append({
|
||||||
|
'Destination': route.dst,
|
||||||
|
'RouteType': 1
|
||||||
|
})
|
||||||
|
# we need to add the on-link routes first
|
||||||
|
res['StaticRoutes'] += nonlink
|
||||||
|
|
||||||
|
logger.info(res)
|
||||||
|
return jsonify(res)
|
||||||
|
|
||||||
@app.route('/NetworkDriver.Leave', methods=['POST'])
|
@app.route('/NetworkDriver.Leave', methods=['POST'])
|
||||||
def leave():
|
def leave():
|
||||||
|
Loading…
Reference in New Issue
Block a user