Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f505b52 authored by Amir Levy's avatar Amir Levy Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa: warn if header type isn't compatible with mode



In case of Vlan mode, verify that registered header is of
correct type and warn otherwise.

Change-Id: Ic5c529f1c9cabf77d0ef9f996105014d4a272c7c
Signed-off-by: default avatarAmir Levy <alevy@codeaurora.org>
parent 88c251ac
Loading
Loading
Loading
Loading
+38 −2
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, 2020 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -12,6 +12,7 @@

#include <linux/ipa_uc_offload.h>
#include <linux/msm_ipa.h>
#include <linux/if_vlan.h>
#include "../ipa_common_i.h"
#include "../ipa_v3/ipa_pm.h"

@@ -200,7 +201,7 @@ static int ipa_uc_offload_ntn_reg_intf(
	struct ipa_ioc_rx_intf_prop rx_prop[2];
	int ret = 0;
	u32 len;

	bool is_vlan_mode;

	IPA_UC_OFFLOAD_DBG("register interface for netdev %s\n",
					 inp->netdev_name);
@@ -225,6 +226,41 @@ static int ipa_uc_offload_ntn_reg_intf(
		goto fail_alloc;
	}

	ret = ipa_is_vlan_mode(IPA_VLAN_IF_ETH, &is_vlan_mode);
	if (ret) {
		IPA_UC_OFFLOAD_ERR("get vlan mode failed\n");
		goto fail;
	}

	if (is_vlan_mode) {
		if ((inp->hdr_info[0].hdr_type != IPA_HDR_L2_802_1Q) ||
			(inp->hdr_info[1].hdr_type != IPA_HDR_L2_802_1Q)) {
			IPA_UC_OFFLOAD_ERR(
				"hdr_type mismatch in vlan mode\n");
			WARN_ON_RATELIMIT_IPA(1);
			ret = -EFAULT;
			goto fail;
		}
		IPA_UC_OFFLOAD_DBG("vlan HEADER type compatible\n");

		if ((inp->hdr_info[0].hdr_len <
			(ETH_HLEN + VLAN_HLEN)) ||
			(inp->hdr_info[1].hdr_len <
			(ETH_HLEN + VLAN_HLEN))) {
			IPA_UC_OFFLOAD_ERR(
				"hdr_len shorter than vlan len (%u) (%u)\n"
				, inp->hdr_info[0].hdr_len
				, inp->hdr_info[1].hdr_len);
			WARN_ON_RATELIMIT_IPA(1);
			ret = -EFAULT;
			goto fail;
		}

		IPA_UC_OFFLOAD_DBG("vlan HEADER len compatible (%u) (%u)\n",
			inp->hdr_info[0].hdr_len,
			inp->hdr_info[1].hdr_len);
	}

	if (ipa_commit_partial_hdr(hdr, ntn_ctx->netdev_name, inp->hdr_info)) {
		IPA_UC_OFFLOAD_ERR("fail to commit partial headers\n");
		ret = -EFAULT;