diff mbox series

teamd/lacp: silence ignore none LACP frames

Message ID 20200526105933.3485343-1-liuhangbin@gmail.com (mailing list archive)
State New
Headers show
Series teamd/lacp: silence ignore none LACP frames | expand

Commit Message

Hangbin Liu May 26, 2020, 10:59 a.m. UTC
According to 802.3, Annex 43B, section 4, aside from LACP, the Slow
Protocol linktype is also to be used by other protocols, like 0x02 for
LAMP, 0x03 for OAM. So let's only check LACP frames. For none LACP
protocols, just silence ignore.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 teamd/teamd_runner_lacp.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Hangbin Liu June 9, 2020, 4:44 a.m. UTC | #1
Hi Jiri,

Would you please help review this patch.

Thanks
Hangbin
On Tue, May 26, 2020 at 06:59:33PM +0800, Hangbin Liu wrote:
> According to 802.3, Annex 43B, section 4, aside from LACP, the Slow
> Protocol linktype is also to be used by other protocols, like 0x02 for
> LAMP, 0x03 for OAM. So let's only check LACP frames. For none LACP
> protocols, just silence ignore.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Jiri Pirko June 11, 2020, 12:24 p.m. UTC | #2
Tue, May 26, 2020 at 12:59:33PM CEST, liuhangbin@gmail.com wrote:
>According to 802.3, Annex 43B, section 4, aside from LACP, the Slow
>Protocol linktype is also to be used by other protocols, like 0x02 for
>LAMP, 0x03 for OAM. So let's only check LACP frames. For none LACP
>protocols, just silence ignore.
>
>Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

applied. Thanks!
diff mbox series

Patch

diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 11d02f1..9437f05 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -96,17 +96,27 @@  static void lacpdu_init(struct lacpdu *lacpdu)
 
 static bool lacpdu_check(struct lacpdu *lacpdu)
 {
+	/*
+	 * According to Annex 43B, section 4, aside from LACP, the Slow
+	 * Protocol linktype is also to be used by other protocols, like
+	 * 0x02 for LAMP, 0x03 for OAM. So for none LACP protocols, just
+	 * silence ignore.
+	 */
+	if (lacpdu->subtype != 0x01)
+		return false;
+
 	/*
 	 * According to 43.4.12 version_number, tlv_type and reserved fields
 	 * should not be checked.
 	 */
 
-	if (lacpdu->subtype		!= 0x01 ||
-	    lacpdu->actor_info_len	!= 0x14 ||
+	if (lacpdu->actor_info_len	!= 0x14 ||
 	    lacpdu->partner_info_len	!= 0x14 ||
 	    lacpdu->collector_info_len	!= 0x10 ||
-	    lacpdu->terminator_info_len	!= 0x00)
+	    lacpdu->terminator_info_len	!= 0x00) {
+		teamd_log_warn("malformed LACP PDU came.");
 		return false;
+	}
 	return true;
 }
 
@@ -1088,10 +1098,8 @@  static int lacpdu_recv(struct lacp_port *lacp_port)
 	if (!teamd_port_present(lacp_port->ctx, lacp_port->tdport))
 		return 0;
 
-	if (!lacpdu_check(&lacpdu)) {
-		teamd_log_warn("malformed LACP PDU came.");
+	if (!lacpdu_check(&lacpdu))
 		return 0;
-	}
 
 	/* Check if we have correct info about the other side */
 	if (memcmp(&lacpdu.actor, &lacp_port->partner,