From patchwork Thu Nov 4 17:21:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 514 Return-Path: Received: from nm7.bullet.mail.ukl.yahoo.com (nm7.bullet.mail.ukl.yahoo.com [217.146.182.248]) by open-mesh.org (Postfix) with SMTP id 4568E154561 for ; Thu, 4 Nov 2010 18:23:27 +0100 (CET) Received: from [217.146.183.209] by nm7.bullet.mail.ukl.yahoo.com with NNFMP; 04 Nov 2010 17:23:26 -0000 Received: from [217.146.183.72] by tm2.bullet.mail.ukl.yahoo.com with NNFMP; 04 Nov 2010 17:23:26 -0000 Received: from [127.0.0.1] by omp1033.mail.ukl.yahoo.com with NNFMP; 04 Nov 2010 17:23:26 -0000 X-Yahoo-Newman-Id: 594717.29403.bm@omp1033.mail.ukl.yahoo.com Received: (qmail 28711 invoked from network); 4 Nov 2010 17:23:26 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=wwfOhhwGN+UbMiMP4OnFVu3TyjvFxz897Ch1h71hsbwpMG2bRCnCrxKywsbn1ULr8CiLbVs5aw4PWKpUXyWBeabjmBA7M6aZakDYBxIh+egU2Lsi3wY2ndV6/TnNpLvV+bmpAVQHblQmF01OZB6x6KL8zRH75gcqXxz8i6+Owt0= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1288891406; bh=OrBmxwKSX7CkzOjekHFZXOy7xg1kd3Ixcmu5vIDm+x0=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=IulZ7XnSqdOEGQy4SQXfYwHPZ4TzmNwg6SvEPorsvRsCFUFgzgdmnaupIsqSnqDWCDkUldgBHbcWP7YbAOYbnqXCGgSHoNrwMoKMWFIy3vm+11uDIrEsecnW/5mq+DrwL5miJU3Ww9XhS/+AY7ccWCeesxSudssyvYMw582bJ6g= Received: from localhost (lindner_marek@78.225.40.81 with plain) by smtp133.mail.ukl.yahoo.com with SMTP; 04 Nov 2010 17:23:26 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: GEWJsjUVM1lc6te6wg1Nqn0_HYbARRhPC3_2UpR3iPmQCyG 0WGWBqeqMJXeeZWq10i.QRWm74B1bsNzF2PZ5_Jc2wO_qPvk0XrwAZZFkRhW fjF2wMl7rEW3WM8gqp8K9SEZFtNCWmU9hWNewlJxB2cLnuubbtE2KaqHinqV VGa9c4H8lVeGY_X6Ri.xfSZ4oU5nQ3S4vgd0Z2_YmxrK.12hNU6.av91Ery9 Usv21nCFbA72n.YwKdX1OyRagJztN_CdAXzSjz6guVAo7jjIT X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 4 Nov 2010 18:21:00 +0100 Message-Id: <1288891265-16035-3-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <201011041820.44518.lindner_marek@yahoo.de> References: <201011041820.44518.lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 3/8] batman-adv: move gateway selection class into its own sysfs file X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 17:23:28 -0000 The Linux kernel guidelines require each sysfs file to have a single value / purpose, therefore it is necessary to split up the sysfs gateway files. Signed-off-by: Marek Lindner --- batman-adv/bat_sysfs.c | 10 ++++++++++ batman-adv/gateway_client.c | 6 +++--- batman-adv/gateway_common.c | 5 ++++- batman-adv/routing.c | 5 ++++- batman-adv/soft-interface.c | 1 + batman-adv/types.h | 1 + 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/batman-adv/bat_sysfs.c b/batman-adv/bat_sysfs.c index 8e3dbef..0f39213 100644 --- a/batman-adv/bat_sysfs.c +++ b/batman-adv/bat_sysfs.c @@ -251,6 +251,12 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, return count; } +static void post_gw_deselect(struct net_device *net_dev) +{ + struct bat_priv *bat_priv = netdev_priv(net_dev); + gw_deselect(bat_priv); +} + static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr, char *buff) { @@ -261,6 +267,7 @@ static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr, switch (gw_mode) { case GW_MODE_CLIENT: + gw_class = atomic_read(&bat_priv->gw_sel_class); bytes_written = sprintf(buff, "%s (gw_class: %i)\n", GW_MODE_CLIENT_NAME, gw_class); break; @@ -298,6 +305,8 @@ static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode); BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL); BAT_ATTR_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); +BAT_ATTR_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE, + post_gw_deselect); #ifdef CONFIG_BATMAN_ADV_DEBUG BAT_ATTR_UINT(log_level, S_IRUGO | S_IWUSR, 0, 3, NULL); #endif @@ -310,6 +319,7 @@ static struct bat_attribute *mesh_attrs[] = { &bat_attr_gw_mode, &bat_attr_orig_interval, &bat_attr_hop_penalty, + &bat_attr_gw_sel_class, #ifdef CONFIG_BATMAN_ADV_DEBUG &bat_attr_log_level, #endif diff --git a/batman-adv/gateway_client.c b/batman-adv/gateway_client.c index 2e05dd4..56c52b0 100644 --- a/batman-adv/gateway_client.c +++ b/batman-adv/gateway_client.c @@ -116,7 +116,7 @@ void gw_election(struct bat_priv *bat_priv) if (gw_node->deleted) continue; - switch (atomic_read(&bat_priv->gw_class)) { + switch (atomic_read(&bat_priv->gw_sel_class)) { case 1: /* fast connection */ gw_srv_class_to_kbit(gw_node->orig_node->gw_flags, &down, &up); @@ -215,8 +215,8 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) * if the routing class is greater than 3 the value tells us how much * greater the TQ value of the new gateway must be **/ - if ((atomic_read(&bat_priv->gw_class) > 3) && - (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_class))) + if ((atomic_read(&bat_priv->gw_sel_class) > 3) && + (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) return; bat_dbg(DBG_BATMAN, bat_priv, diff --git a/batman-adv/gateway_common.c b/batman-adv/gateway_common.c index a88ce41..330167e 100644 --- a/batman-adv/gateway_common.c +++ b/batman-adv/gateway_common.c @@ -236,12 +236,15 @@ next: switch (gw_mode_tmp) { case GW_MODE_CLIENT: + gw_class_tmp = atomic_read(&bat_priv->gw_sel_class); if ((gw_mode_tmp == GW_MODE_CLIENT) && (!gw_class_tmp)) gw_class_tmp = 20; bat_info(net_dev, "Changing gateway mode from: '%s' to: '%s' " - "(gw_class: %ld)\n", + "(gw_sel_class: %ld)\n", gw_mode_curr_str, gw_mode_tmp_str, gw_class_tmp); + + atomic_set(&bat_priv->gw_sel_class, gw_class_tmp); break; case GW_MODE_SERVER: if (!down) diff --git a/batman-adv/routing.c b/batman-adv/routing.c index e75337d..9f31167 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -32,6 +32,7 @@ #include "ring_buffer.h" #include "vis.h" #include "aggregation.h" +#include "gateway_common.h" #include "gateway_client.h" #include "unicast.h" @@ -330,7 +331,9 @@ update_gw: orig_node->gw_flags = batman_packet->gw_flags; /* restart gateway selection if fast or late switching was enabled */ - if ((orig_node->gw_flags) && (atomic_read(&bat_priv->gw_class) > 2)) + if ((orig_node->gw_flags) && + (atomic_read(&bat_priv->gw_mode) == GW_MODE_CLIENT) && + (atomic_read(&bat_priv->gw_sel_class) > 2)) gw_check_election(bat_priv, orig_node); } diff --git a/batman-adv/soft-interface.c b/batman-adv/soft-interface.c index 836c452..7b2673c 100644 --- a/batman-adv/soft-interface.c +++ b/batman-adv/soft-interface.c @@ -591,6 +591,7 @@ struct net_device *softif_create(char *name) atomic_set(&bat_priv->bonding, 0); atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); atomic_set(&bat_priv->gw_mode, GW_MODE_OFF); + atomic_set(&bat_priv->gw_sel_class, 0); atomic_set(&bat_priv->gw_class, 0); atomic_set(&bat_priv->orig_interval, 1000); atomic_set(&bat_priv->hop_penalty, 10); diff --git a/batman-adv/types.h b/batman-adv/types.h index 2678ce1..b68add4 100644 --- a/batman-adv/types.h +++ b/batman-adv/types.h @@ -128,6 +128,7 @@ struct bat_priv { atomic_t fragmentation; /* boolean */ atomic_t vis_mode; /* VIS_TYPE_* */ atomic_t gw_mode; /* GW_MODE_* */ + atomic_t gw_sel_class; /* uint */ atomic_t gw_class; /* uint */ atomic_t orig_interval; /* uint */ atomic_t hop_penalty; /* uint */