Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/610126/?format=api
{ "id": 610126, "url": "http://patchwork.ozlabs.org/api/patches/610126/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1460542112-20166-3-git-send-email-harshitha.ramamurthy@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1460542112-20166-3-git-send-email-harshitha.ramamurthy@intel.com>", "list_archive_url": null, "date": "2016-04-13T10:08:22", "name": "[next,S34,02/12] i40e: Limit the number of mac and vlan addresses that can be added for VFs", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "c369cd26bf62a51f466ead2dff1d08a70305a1e3", "submitter": { "id": 68642, "url": "http://patchwork.ozlabs.org/api/people/68642/?format=api", "name": "Harshitha Ramamurthy", "email": "harshitha.ramamurthy@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1460542112-20166-3-git-send-email-harshitha.ramamurthy@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/610126/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/610126/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@lists.osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@osuosl.org" ], "Received": [ "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ozlabs.org (Postfix) with ESMTP id 3qlX503b7nz9sD5\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Apr 2016 04:14:28 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id C5B0833A4A;\n\tWed, 13 Apr 2016 18:14:27 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 6kgHDEHuQaoQ; Wed, 13 Apr 2016 18:14:22 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 516D533A39;\n\tWed, 13 Apr 2016 18:14:18 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 3460D1C10B8\n\tfor <intel-wired-lan@osuosl.org>;\n\tWed, 13 Apr 2016 18:14:16 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 2E7F233A00\n\tfor <intel-wired-lan@osuosl.org>;\n\tWed, 13 Apr 2016 18:14:16 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 2tE-sExIN1Sj for <intel-wired-lan@osuosl.org>;\n\tWed, 13 Apr 2016 18:14:11 +0000 (UTC)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby silver.osuosl.org (Postfix) with ESMTP id 5203433A0E\n\tfor <intel-wired-lan@osuosl.org>;\n\tWed, 13 Apr 2016 18:14:11 +0000 (UTC)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga102.jf.intel.com with ESMTP; 13 Apr 2016 11:14:11 -0700", "from harshitha-linux1.jf.intel.com ([10.166.45.81])\n\tby fmsmga002.fm.intel.com with ESMTP; 13 Apr 2016 11:14:11 -0700" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.24,480,1455004800\"; d=\"scan'208\";a=\"957967572\"", "From": "Harshitha Ramamurthy <harshitha.ramamurthy@intel.com>", "To": "intel-wired-lan@osuosl.org", "Date": "Wed, 13 Apr 2016 03:08:22 -0700", "Message-Id": "<1460542112-20166-3-git-send-email-harshitha.ramamurthy@intel.com>", "X-Mailer": "git-send-email 2.4.3", "In-Reply-To": "<1460542112-20166-1-git-send-email-harshitha.ramamurthy@intel.com>", "References": "<1460542112-20166-1-git-send-email-harshitha.ramamurthy@intel.com>", "Subject": "[Intel-wired-lan] [next PATCH S34 02/12] i40e: Limit the number of\n\tmac and vlan addresses that can be added for VFs", "X-BeenThere": "intel-wired-lan@lists.osuosl.org", "X-Mailman-Version": "2.1.18-1", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>", "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>", "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>" }, "content": "From: Anjali Singhai Jain <anjali.singhai@intel.com>\n\nIf the VF is privileged/trusted it can do as it may please including\nbut not limited to hogging resources and playing unfair.\nBut if the VF is not privileged/trusted it still can add some number\n(8) of MAC and VLAN addresses.\nOther restrictions with respect to Port VLAN and normal VLAN still apply\nto not privileged/trusted VF.\n\nSigned-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>\nChange-Id: I3a9529201b184c8873e1ad2e300aff468c9e6296\n---\nTesting Hints :\nWith this a non trusted VF can add up to 8 mac addresses and up to\n(8) vlan addresses if not under port vlan.\n\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 25 ++++++++++++++++++++--\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h | 3 +++\n 2 files changed, 26 insertions(+), 2 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex e2c3149..747cb28 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -1831,6 +1831,10 @@ error_param:\n \t\t\t\t (u8 *)&stats, sizeof(stats));\n }\n \n+/* If the VF is not trusted restrict the number of MAC/VLAN it can program */\n+#define I40E_VC_MAX_MAC_ADDR_PER_VF 8\n+#define I40E_VC_MAX_VLAN_PER_VF 8\n+\n /**\n * i40e_check_vf_permission\n * @vf: pointer to the VF info\n@@ -1863,6 +1867,11 @@ static inline int i40e_check_vf_permission(struct i40e_vf *vf, u8 *macaddr)\n \t\tdev_err(&pf->pdev->dev,\n \t\t\t\"VF attempting to override administratively set MAC address, reload the VF driver to resume normal operation\\n\");\n \t\tret = -EPERM;\n+\t} else if ((vf->num_mac >= I40E_VC_MAX_MAC_ADDR_PER_VF) &&\n+\t\t !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {\n+\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\"VF is not trusted, switch the VF to trusted to add more functionality\\n\");\n+\t\tret = -EPERM;\n \t}\n \treturn ret;\n }\n@@ -1924,6 +1933,8 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)\n \t\t\tret = I40E_ERR_PARAM;\n \t\t\tspin_unlock_bh(&vsi->mac_filter_list_lock);\n \t\t\tgoto error_param;\n+\t\t} else {\n+\t\t\tvf->num_mac++;\n \t\t}\n \t}\n \tspin_unlock_bh(&vsi->mac_filter_list_lock);\n@@ -1982,6 +1993,8 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)\n \t\t\tret = I40E_ERR_INVALID_MAC_ADDR;\n \t\t\tspin_unlock_bh(&vsi->mac_filter_list_lock);\n \t\t\tgoto error_param;\n+\t\t} else {\n+\t\t\tvf->num_mac--;\n \t\t}\n \n \tspin_unlock_bh(&vsi->mac_filter_list_lock);\n@@ -2016,8 +2029,13 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)\n \ti40e_status aq_ret = 0;\n \tint i;\n \n+\tif ((vf->num_vlan >= I40E_VC_MAX_VLAN_PER_VF) &&\n+\t !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {\n+\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\"VF is not trusted, switch the VF to trusted to add more VLAN addresses\\n\");\n+\t\tgoto error_param;\n+\t}\n \tif (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||\n-\t !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps) ||\n \t !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n@@ -2041,6 +2059,8 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)\n \tfor (i = 0; i < vfl->num_elements; i++) {\n \t\t/* add new VLAN filter */\n \t\tint ret = i40e_vsi_add_vlan(vsi, vfl->vlan_id[i]);\n+\t\tif (!ret)\n+\t\t\tvf->num_vlan++;\n \n \t\tif (test_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states))\n \t\t\ti40e_aq_set_vsi_uc_promisc_on_vlan(&pf->hw, vsi->seid,\n@@ -2083,7 +2103,6 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)\n \tint i;\n \n \tif (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||\n-\t !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps) ||\n \t !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {\n \t\taq_ret = I40E_ERR_PARAM;\n \t\tgoto error_param;\n@@ -2104,6 +2123,8 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)\n \n \tfor (i = 0; i < vfl->num_elements; i++) {\n \t\tint ret = i40e_vsi_kill_vlan(vsi, vfl->vlan_id[i]);\n+\t\tif (!ret)\n+\t\t\tvf->num_vlan--;\n \n \t\tif (test_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states))\n \t\t\ti40e_aq_set_vsi_uc_promisc_on_vlan(&pf->hw, vsi->seid,\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\nindex 8cbf579..bf54873 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\n@@ -111,6 +111,9 @@ struct i40e_vf {\n \tbool link_forced;\n \tbool link_up;\t\t/* only valid if VF link is forced */\n \tbool spoofchk;\n+\tu16 num_mac;\n+\tu16 num_vlan;\n+\n \t/* RDMA Client */\n \tstruct i40e_virtchnl_iwarp_qvlist_info *qvlist_info;\n };\n", "prefixes": [ "next", "S34", "02/12" ] }