From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Cc: bridge@lists.linux-foundation.org, mst@redhat.com,
Vlad Yasevich <vyasevic@redhat.com>
Subject: [PATCH v2 net-next 2/6] bridge: make flags sysfs interface a little bit more extensible
Date: Fri, 19 Apr 2013 16:52:46 -0400 [thread overview]
Message-ID: <1366404770-28523-3-git-send-email-vyasevic@redhat.com> (raw)
In-Reply-To: <1366404770-28523-1-git-send-email-vyasevic@redhat.com>
Some changes of the flags may need to trigger additional actions.
Make the flag change function generic and have the per-attribute
function call that.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
net/bridge/br_sysfs_if.c | 39 ++++++++++++++++++++++++++++-----------
1 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 1f28cd4..606362c 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -25,6 +25,10 @@ struct brport_attribute {
ssize_t (*show)(struct net_bridge_port *, char *);
int (*store)(struct net_bridge_port *, unsigned long);
};
+static ssize_t show_flag(struct net_bridge_port *p, char *buf,
+ unsigned long mask);
+static int store_flag(struct net_bridge_port *p, unsigned long v,
+ unsigned long mask);
#define BRPORT_ATTR(_name,_mode,_show,_store) \
const struct brport_attribute brport_attr_##_name = { \
@@ -37,24 +41,37 @@ const struct brport_attribute brport_attr_##_name = { \
#define BRPORT_ATTR_FLAG(_name, _mask) \
static ssize_t show_##_name(struct net_bridge_port *p, char *buf) \
{ \
- return sprintf(buf, "%d\n", !!(p->flags & _mask)); \
+ return show_flag(p, buf, _mask); \
} \
static int store_##_name(struct net_bridge_port *p, unsigned long v) \
{ \
- unsigned long flags = p->flags; \
- if (v) \
- flags |= _mask; \
- else \
- flags &= ~_mask; \
- if (flags != p->flags) { \
- p->flags = flags; \
- br_ifinfo_notify(RTM_NEWLINK, p); \
- } \
- return 0; \
+ return store_flag(p, v, _mask); \
} \
static BRPORT_ATTR(_name, S_IRUGO | S_IWUSR, \
show_##_name, store_##_name)
+static ssize_t show_flag(struct net_bridge_port *p, char *buf,
+ unsigned long mask)
+{
+ return sprintf(buf, "%d\n", !!(p->flags & mask));
+}
+
+static int store_flag(struct net_bridge_port *p, unsigned long v,
+ unsigned long mask)
+{
+ unsigned long flags = p->flags;
+
+ if (v)
+ flags |= mask;
+ else
+ flags &= ~mask;
+
+ if (flags != p->flags) {
+ p->flags = flags;
+ br_ifinfo_notify(RTM_NEWLINK, p);
+ }
+ return 0;
+}
static ssize_t show_path_cost(struct net_bridge_port *p, char *buf)
{
--
1.7.7.6
next prev parent reply other threads:[~2013-04-19 20:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 20:52 [PATCH v2 net-next 0/6] Allow bridge to function in non-promisc mode Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 1/6] bridge: Allow an ability to designate an uplink port Vlad Yasevich
2013-04-19 20:52 ` Vlad Yasevich [this message]
2013-04-19 20:54 ` [PATCH v2 net-next 2/6] bridge: make flags sysfs interface a little bit more extensible Stephen Hemminger
2013-04-19 21:35 ` Vlad Yasevich
2013-04-19 20:55 ` Stephen Hemminger
2013-04-19 21:33 ` Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 3/6] bridge: Implement IFF_UNICAST_FLT Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 4/6] bridge: Allow user to program hw addresses to uplink devices Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 5/6] bridge: Automatically set promisc on uplink ports Vlad Yasevich
2013-04-19 20:52 ` [PATCH v2 net-next 6/6] bridge: Store bridge mac to uplinks Vlad Yasevich
2013-04-19 20:58 ` [PATCH v2 net-next 0/6] Allow bridge to function in non-promisc mode Stephen Hemminger
2013-04-19 21:48 ` Vlad Yasevich
2013-04-25 15:56 ` Stephen Hemminger
2013-04-25 16:45 ` Michael S. Tsirkin
2013-04-25 17:35 ` Stephen Hemminger
2013-04-25 21:13 ` Michael S. Tsirkin
2013-05-02 17:23 ` Stephen Hemminger
2013-05-02 17:41 ` Vlad Yasevich
2013-05-02 18:14 ` Stephen Hemminger
2013-05-02 18:37 ` Michael S. Tsirkin
2013-05-02 21:16 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366404770-28523-3-git-send-email-vyasevic@redhat.com \
--to=vyasevic@redhat.com \
--cc=bridge@lists.linux-foundation.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).