static executor: if vrf-table is set, apply the static route to a specific table
This commit is contained in:
		
							parent
							
								
									184526401b
								
							
						
					
					
						commit
						9caffc01c2
					
				
					 3 changed files with 22 additions and 2 deletions
				
			
		|  | @ -1,5 +1,8 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| VRF_TABLE="" | ||||
| [ -n "$IF_VRF_TABLE" ] && VRF_TABLE="table $IF_VRF_TABLE" | ||||
| 
 | ||||
| addr_family() { | ||||
| 	if [ "$1" != "${1#*[0-9].[0-9]}" ]; then | ||||
| 		echo "-4" | ||||
|  | @ -20,7 +23,7 @@ configure_addresses() { | |||
| configure_gateways() { | ||||
| 	for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do | ||||
| 		addrfam=$(addr_family $i) | ||||
| 		${MOCK} ip $addrfam route $1 default via $i | ||||
| 		${MOCK} ip $addrfam route $1 default via $i $VRF_TABLE | ||||
| 	done | ||||
| } | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										1
									
								
								tests/fixtures/vrf.interfaces
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								tests/fixtures/vrf.interfaces
									
										
									
									
										vendored
									
									
								
							|  | @ -1,5 +1,6 @@ | |||
| iface vrf-red | ||||
|     vrf-table 1 | ||||
|     gateway 203.0.113.2 | ||||
| 
 | ||||
| auto eth0 | ||||
| iface eth0 | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ | |||
| EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/static" | ||||
| FIXTURES="$(atf_get_srcdir)/../fixtures" | ||||
| 
 | ||||
| tests_init up down | ||||
| tests_init up down vrf_up vrf_down | ||||
| 
 | ||||
| up_body() { | ||||
| 	export IFACE=eth0 PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/static-eth0.interfaces" | ||||
|  | @ -25,3 +25,19 @@ down_body() { | |||
| 		-o match:'route del default via 2001:db8:1000:2::1' \ | ||||
| 		${EXECUTOR} | ||||
| } | ||||
| 
 | ||||
| vrf_up_body() { | ||||
| 	export IFACE=vrf-red PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/vrf.interfaces" \ | ||||
| 		IF_VRF_TABLE=1 | ||||
| 	atf_check -s exit:0 \ | ||||
| 		-o match:'route add default via 203.0.113.2 table 1' \ | ||||
| 		${EXECUTOR} | ||||
| } | ||||
| 
 | ||||
| vrf_down_body() { | ||||
| 	export IFACE=vrf-red PHASE=down MOCK=echo INTERFACES_FILE="$FIXTURES/vrf.interfaces" \ | ||||
| 		IF_VRF_TABLE=1 | ||||
| 	atf_check -s exit:0 \ | ||||
| 		-o match:'route del default via 203.0.113.2 table 1' \ | ||||
| 		${EXECUTOR} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue