Damans227 commented on code in PR #14357:
URL: https://github.com/apache/cloudstack/pull/14357#discussion_r4231451855


##########
core/src/main/java/com/cloud/agent/api/routing/SetNetworkACLCommand.java:
##########
@@ -97,6 +103,45 @@ public String[][] generateFwRules() {
         return result;
     }
 
+    /**
+     * The VR applies ports only to a rule it is sent as tcp or udp, and an 
ICMP type and code only to one
+     * sent as icmp; any other protocol goes to it as a bare number, which 
matches the whole protocol. So
+     * send protocol number 1 as icmp, and 6 and 17 as tcp and udp when the 
rule has ports, whatever form
+     * or case they were stored in. Without ports 6 and 17 stay bare numbers, 
which match the whole
+     * protocol on every VR path; a tcp or udp rule without ports has matched 
port 0 only on the iptables
+     * path (see #14363).
+     */
+    protected static String normalizeProtocol(String protocol, boolean 
hasPorts) {
+        if (protocol == null) {
+            return null;
+        }
+        String p = protocol.trim().toLowerCase(Locale.ROOT);
+        if (!StringUtils.isNumeric(p)) {
+            return p;
+        }
+        int number;
+        try {
+            number = Integer.parseInt(p);
+        } catch (NumberFormatException e) {
+            return p;
+        }
+        if (number == NetUtils.ICMP_PROTO_NUMBER) {
+            return NetUtils.ICMP_PROTO;
+        }
+        if (hasPorts && number == TCP_PROTO_NUMBER) {

Review Comment:
   should this go in the release notes? existing protocol 6 or 17 rules with 
ports have been matching all tcp or udp, and will quietly start matching only 
those ports once the router reapplies them



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to