Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 637394 | Differences between
and this patch

Collapse All | Expand All

(-)a/net/iproute2.sh (-6 / +27 lines)
Lines 204-209 _add_address() Link Here
204
	return $rc
204
	return $rc
205
}
205
}
206
206
207
_nodev_route_type()
208
{
209
	case "$1" in
210
		throw|unreachable|prohibit|blackhole) return 0 ;;
211
		*) return 1 ;;
212
	esac
213
}
214
207
_add_route()
215
_add_route()
208
{
216
{
209
	local family=
217
	local family=
Lines 219-225 _add_route() Link Here
219
		shift
227
		shift
220
	fi
228
	fi
221
229
222
	if [ $# -eq 3 ]; then
230
	local nodev=false
231
232
	if _nodev_route_type "$2"; then
233
		nodev=true
234
	elif [ $# -eq 3 ]; then
223
		set -- "$1" "$2" via "$3"
235
		set -- "$1" "$2" via "$3"
224
	elif [ "$3" = "gw" ]; then
236
	elif [ "$3" = "gw" ]; then
225
		local one=$1 two=$2
237
		local one=$1 two=$2
Lines 233-238 _add_route() Link Here
233
			metric) metric=$2 ; cmd="${cmd} metric $2" ; shift ; have_metric=true ;;
245
			metric) metric=$2 ; cmd="${cmd} metric $2" ; shift ; have_metric=true ;;
234
			netmask) x="/$(_netmask2cidr "$2")" ; cmd="${cmd}${x}" ; cmd_nometric="${cmd}${x}" ; shift;;
246
			netmask) x="/$(_netmask2cidr "$2")" ; cmd="${cmd}${x}" ; cmd_nometric="${cmd}${x}" ; shift;;
235
			-host|-net);;
247
			-host|-net);;
248
			throw|unreachable|prohibit|blackhole) cmd="${cmd} ${1}" ;;
236
			*) cmd="${cmd} ${1}" ; cmd_nometric="${cmd_nometric} ${1}" ;;
249
			*) cmd="${cmd} ${1}" ; cmd_nometric="${cmd_nometric} ${1}" ;;
237
		esac
250
		esac
238
		shift
251
		shift
Lines 247-259 _add_route() Link Here
247
	fi
260
	fi
248
261
249
	# Check for route already existing:
262
	# Check for route already existing:
250
	ip ${family} route show ${cmd_nometric} dev "${IFACE}" 2>/dev/null | \
263
	ip ${family} route show ${cmd_nometric} 2>/dev/null | \
251
		fgrep -sq "${cmd%% *}"
264
		fgrep -sq "${cmd%% *}"
252
	route_already_exists=$?
265
	route_already_exists=$?
253
266
254
	veinfo ip ${family} route append ${cmd} dev "${IFACE}"
267
	# Some routes are incompatible with dev option
255
	ip ${family} route append ${cmd} dev "${IFACE}"
268
	if yesno "${nodev}"; then
256
	rc=$?
269
		veinfo ip ${family} route append ${cmd}
270
		ip ${family} route append ${cmd}
271
		rc=$?
272
	else
273
		veinfo ip ${family} route append ${cmd} dev "${IFACE}"
274
		ip ${family} route append ${cmd} dev "${IFACE}"
275
		rc=$?
276
	fi
277
257
	# Check return code in some cases
278
	# Check return code in some cases
258
	if [ $rc -ne 0 ]; then
279
	if [ $rc -ne 0 ]; then
259
		# If the route already exists, our default behavior is to WARN but continue.
280
		# If the route already exists, our default behavior is to WARN but continue.
Lines 268-274 _add_route() Link Here
268
				*) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;;
289
				*) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;;
269
			esac
290
			esac
270
			eval $msgfunc "Route '$cmd_nometric' already existed:"
291
			eval $msgfunc "Route '$cmd_nometric' already existed:"
271
			eval $msgfunc \"$(ip $family route show ${cmd_nometric} dev "${IFACE}" 2>&1)\"
292
			eval $msgfunc \"$(ip $family route show ${cmd_nometric} 2>&1)\"
272
		else
293
		else
273
			: # TODO: Handle other errors
294
			: # TODO: Handle other errors
274
		fi
295
		fi

Return to bug 637394