Skip to content

Commit af61576

Browse files
Mic92davem330
authored andcommitted
bridge: add ageing_time, stp_state, priority over netlink
Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 99c4a26 commit af61576

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

include/uapi/linux/if_link.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ enum {
225225
IFLA_BR_FORWARD_DELAY,
226226
IFLA_BR_HELLO_TIME,
227227
IFLA_BR_MAX_AGE,
228+
IFLA_BR_AGEING_TIME,
229+
IFLA_BR_STP_STATE,
230+
IFLA_BR_PRIORITY,
228231
__IFLA_BR_MAX,
229232
};
230233

net/bridge/br_netlink.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = {
733733
[IFLA_BR_FORWARD_DELAY] = { .type = NLA_U32 },
734734
[IFLA_BR_HELLO_TIME] = { .type = NLA_U32 },
735735
[IFLA_BR_MAX_AGE] = { .type = NLA_U32 },
736+
[IFLA_BR_AGEING_TIME] = { .type = NLA_U32 },
737+
[IFLA_BR_STP_STATE] = { .type = NLA_U32 },
738+
[IFLA_BR_PRIORITY] = { .type = NLA_U16 },
736739
};
737740

738741
static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
@@ -762,6 +765,24 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
762765
return err;
763766
}
764767

768+
if (data[IFLA_BR_AGEING_TIME]) {
769+
u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
770+
771+
br->ageing_time = clock_t_to_jiffies(ageing_time);
772+
}
773+
774+
if (data[IFLA_BR_STP_STATE]) {
775+
u32 stp_enabled = nla_get_u32(data[IFLA_BR_STP_STATE]);
776+
777+
br_stp_set_enabled(br, stp_enabled);
778+
}
779+
780+
if (data[IFLA_BR_PRIORITY]) {
781+
u32 priority = nla_get_u16(data[IFLA_BR_PRIORITY]);
782+
783+
br_stp_set_bridge_priority(br, priority);
784+
}
785+
765786
return 0;
766787
}
767788

@@ -770,6 +791,9 @@ static size_t br_get_size(const struct net_device *brdev)
770791
return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */
771792
nla_total_size(sizeof(u32)) + /* IFLA_BR_HELLO_TIME */
772793
nla_total_size(sizeof(u32)) + /* IFLA_BR_MAX_AGE */
794+
nla_total_size(sizeof(u32)) + /* IFLA_BR_AGEING_TIME */
795+
nla_total_size(sizeof(u32)) + /* IFLA_BR_STP_STATE */
796+
nla_total_size(sizeof(u16)) + /* IFLA_BR_PRIORITY */
773797
0;
774798
}
775799

@@ -779,10 +803,16 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
779803
u32 forward_delay = jiffies_to_clock_t(br->forward_delay);
780804
u32 hello_time = jiffies_to_clock_t(br->hello_time);
781805
u32 age_time = jiffies_to_clock_t(br->max_age);
806+
u32 ageing_time = jiffies_to_clock_t(br->ageing_time);
807+
u32 stp_enabled = br->stp_enabled;
808+
u16 priority = (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1];
782809

783810
if (nla_put_u32(skb, IFLA_BR_FORWARD_DELAY, forward_delay) ||
784811
nla_put_u32(skb, IFLA_BR_HELLO_TIME, hello_time) ||
785-
nla_put_u32(skb, IFLA_BR_MAX_AGE, age_time))
812+
nla_put_u32(skb, IFLA_BR_MAX_AGE, age_time) ||
813+
nla_put_u32(skb, IFLA_BR_AGEING_TIME, ageing_time) ||
814+
nla_put_u32(skb, IFLA_BR_STP_STATE, stp_enabled) ||
815+
nla_put_u16(skb, IFLA_BR_PRIORITY, priority))
786816
return -EMSGSIZE;
787817

788818
return 0;

0 commit comments

Comments
 (0)