[PATCH] Add new rtnl_bridge_get_port_state api

Roopa Prabhu roopa at cumulusnetworks.com
Tue Jan 8 10:10:23 EST 2013


I will respin this one too :(. With some documentation. thanks.

On 1/8/13 5:33 AM, roopa at cumulusnetworks.com wrote:
> From: roopa<roopa at cumulusnetworks.com>
>
> This patch adds support to get bridge port
> state of an AF_BRIDGE link object.
>
> Signed-off-by: Wilson Kok<wkok at cumulusnetworks.com>
> Signed-off-by: Roopa Prabhu<roopa at cumulusnetworks.com>
> ---
>   include/netlink/route/link/bridge.h |   28 ++++++++++++++++++++++++++++
>   lib/route/link/bridge.c             |   10 ++++++++++
>   2 files changed, 38 insertions(+)
>   create mode 100644 include/netlink/route/link/bridge.h
>
> diff --git a/include/netlink/route/link/bridge.h b/include/netlink/route/link/bridge.h
> new file mode 100644
> index 0000000..3525e98
> --- /dev/null
> +++ b/include/netlink/route/link/bridge.h
> @@ -0,0 +1,28 @@
> +/*
> + * netlink/route/link/bridge.h		Bridge interface
> + *
> + *	This library is free software; you can redistribute it and/or
> + *	modify it under the terms of the GNU Lesser General Public
> + *	License as published by the Free Software Foundation version 2.1
> + *	of the License.
> + *
> + * Copyright (c) 2003-2008 Thomas Graf<tgraf at suug.ch>
> + */
> +
> +#ifndef NETLINK_LINK_BRIDGE_H_
> +#define NETLINK_LINK_BRIDGE_H_
> +
> +#include<netlink/netlink.h>
> +#include<netlink/route/link.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +extern int rtnl_bridge_get_port_state(struct rtnl_link *link);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/route/link/bridge.c b/lib/route/link/bridge.c
> index cd9f462..d3fdf88 100644
> --- a/lib/route/link/bridge.c
> +++ b/lib/route/link/bridge.c
> @@ -92,6 +92,16 @@ static struct rtnl_link_af_ops bridge_ops = {
>   	.ao_compare			=&bridge_compare,
>   };
>
> +int rtnl_bridge_get_port_state(struct rtnl_link *link)
> +{
> +	struct bridge_data *data = link->l_af_data[AF_BRIDGE];
> +
> +	if (data&&  (data->ce_mask&  BRIDGE_ATTR_PORT_STATE))
> +		return data->b_port_state;
> +
> +	return -1;
> +}
> +
>   static void __init bridge_init(void)
>   {
>   	rtnl_link_af_register(&bridge_ops);




More information about the libnl mailing list