Skip to content

Commit 631f707

Browse files
Describe why protocol 6 and 17 without ports stay numbers without relying on the port 0 bug
Signed-off-by: Brad House <bhouse@nexthop.ai>
1 parent b25c728 commit 631f707

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎core/src/main/java/com/cloud/agent/api/routing/SetNetworkACLCommand.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ public String[][] generateFwRules() {
107107
* The VR applies ports only to a rule it is sent as tcp or udp, and an ICMP type and code only to one
108108
* sent as icmp; any other protocol goes to it as a bare number, which matches the whole protocol. So
109109
* send protocol number 1 as icmp, and 6 and 17 as tcp and udp when the rule has ports, whatever form
110-
* or case they were stored in. Without ports 6 and 17 stay bare numbers: that is what matches all of
111-
* TCP or UDP, where a tcp or udp rule without ports would match port 0 only.
110+
* or case they were stored in. Without ports 6 and 17 stay bare numbers, which match the whole
111+
* protocol on every VR path; a tcp or udp rule without ports has matched port 0 only on the iptables
112+
* path (see #14363).
112113
*/
113114
protected static String normalizeProtocol(String protocol, boolean hasPorts) {
114115
if (protocol == null) {

‎core/src/test/java/com/cloud/agent/api/routing/SetNetworkACLCommandTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testTcpAndUdpByProtocolNumberKeepTheirPorts() {
6666

6767
@Test
6868
public void testTcpAndUdpByProtocolNumberWithoutPortsStayWholeProtocol() {
69-
// as tcp or udp with no ports the VR would match port 0 only
69+
// a bare number matches the whole protocol on every VR path
7070
assertEquals("Ingress;6;0;0;10.0.0.0/24;ACCEPT;", generateRule("6", null, null, null, null));
7171
assertEquals("Ingress;17;0;0;10.0.0.0/24;ACCEPT;", generateRule("17", null, null, null, null));
7272
}

0 commit comments

Comments
 (0)