You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "weizhouapache (via GitHub)" <gi...@apache.org> on 2025/12/04 13:29:13 UTC

Re: [PR] [10996] - use 'ip' structured data to safely retrieve default route interface [cloudstack]

weizhouapache commented on code in PR #11800:
URL: https://github.com/apache/cloudstack/pull/11800#discussion_r2589088275


##########
utils/src/main/java/com/cloud/utils/net/NetUtils.java:
##########
@@ -306,7 +306,7 @@ public static String getDefaultEthDevice() {
             final String defDev = Script.runSimpleBashScript("/sbin/route -n get default 2> /dev/null | grep interface | awk '{print $2}'");
             return defDev;
         }
-        return Script.runSimpleBashScript("ip route show default 0.0.0.0/0 | head -1 | awk '{print $5}'");
+        return Script.runSimpleBashScript("ip -j a | jq -r '.[] | .addr_info | map(select(.local == \"'`ip -j r s default | jq -r '.[0] | .prefsrc'`'\")) | .[].label'");

Review Comment:
   oh, then the change makes sense.
   thanks @mosys0815 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org