Skip to content

Commit febf018

Browse files
dpwarddavem330
authored andcommitted
net/802: Implement Multiple Registration Protocol (MRP)
Initial implementation of the Multiple Registration Protocol (MRP) from IEEE 802.1Q-2011, based on the existing implementation of the Generic Attribute Registration Protocol (GARP). Signed-off-by: David Ward <david.ward@ll.mit.edu> Acked-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5b815b5 commit febf018

5 files changed

Lines changed: 1044 additions & 0 deletions

File tree

‎include/linux/netdevice.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,8 @@ struct net_device {
12901290
};
12911291
/* GARP */
12921292
struct garp_port __rcu *garp_port;
1293+
/* MRP */
1294+
struct mrp_port __rcu *mrp_port;
12931295

12941296
/* class/net/name entry */
12951297
struct device dev;

‎include/net/mrp.h‎

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#ifndef _NET_MRP_H
2+
#define _NET_MRP_H
3+
4+
#define MRP_END_MARK 0x0
5+
6+
struct mrp_pdu_hdr {
7+
u8 version;
8+
};
9+
10+
struct mrp_msg_hdr {
11+
u8 attrtype;
12+
u8 attrlen;
13+
};
14+
15+
struct mrp_vecattr_hdr {
16+
__be16 lenflags;
17+
unsigned char firstattrvalue[];
18+
#define MRP_VECATTR_HDR_LEN_MASK cpu_to_be16(0x1FFF)
19+
#define MRP_VECATTR_HDR_FLAG_LA cpu_to_be16(0x2000)
20+
};
21+
22+
enum mrp_vecattr_event {
23+
MRP_VECATTR_EVENT_NEW,
24+
MRP_VECATTR_EVENT_JOIN_IN,
25+
MRP_VECATTR_EVENT_IN,
26+
MRP_VECATTR_EVENT_JOIN_MT,
27+
MRP_VECATTR_EVENT_MT,
28+
MRP_VECATTR_EVENT_LV,
29+
__MRP_VECATTR_EVENT_MAX
30+
};
31+
32+
struct mrp_skb_cb {
33+
struct mrp_msg_hdr *mh;
34+
struct mrp_vecattr_hdr *vah;
35+
unsigned char attrvalue[];
36+
};
37+
38+
static inline struct mrp_skb_cb *mrp_cb(struct sk_buff *skb)
39+
{
40+
BUILD_BUG_ON(sizeof(struct mrp_skb_cb) >
41+
FIELD_SIZEOF(struct sk_buff, cb));
42+
return (struct mrp_skb_cb *)skb->cb;
43+
}
44+
45+
enum mrp_applicant_state {
46+
MRP_APPLICANT_INVALID,
47+
MRP_APPLICANT_VO,
48+
MRP_APPLICANT_VP,
49+
MRP_APPLICANT_VN,
50+
MRP_APPLICANT_AN,
51+
MRP_APPLICANT_AA,
52+
MRP_APPLICANT_QA,
53+
MRP_APPLICANT_LA,
54+
MRP_APPLICANT_AO,
55+
MRP_APPLICANT_QO,
56+
MRP_APPLICANT_AP,
57+
MRP_APPLICANT_QP,
58+
__MRP_APPLICANT_MAX
59+
};
60+
#define MRP_APPLICANT_MAX (__MRP_APPLICANT_MAX - 1)
61+
62+
enum mrp_event {
63+
MRP_EVENT_NEW,
64+
MRP_EVENT_JOIN,
65+
MRP_EVENT_LV,
66+
MRP_EVENT_TX,
67+
MRP_EVENT_R_NEW,
68+
MRP_EVENT_R_JOIN_IN,
69+
MRP_EVENT_R_IN,
70+
MRP_EVENT_R_JOIN_MT,
71+
MRP_EVENT_R_MT,
72+
MRP_EVENT_R_LV,
73+
MRP_EVENT_R_LA,
74+
MRP_EVENT_REDECLARE,
75+
MRP_EVENT_PERIODIC,
76+
__MRP_EVENT_MAX
77+
};
78+
#define MRP_EVENT_MAX (__MRP_EVENT_MAX - 1)
79+
80+
enum mrp_tx_action {
81+
MRP_TX_ACTION_NONE,
82+
MRP_TX_ACTION_S_NEW,
83+
MRP_TX_ACTION_S_JOIN_IN,
84+
MRP_TX_ACTION_S_JOIN_IN_OPTIONAL,
85+
MRP_TX_ACTION_S_IN_OPTIONAL,
86+
MRP_TX_ACTION_S_LV,
87+
};
88+
89+
struct mrp_attr {
90+
struct rb_node node;
91+
enum mrp_applicant_state state;
92+
u8 type;
93+
u8 len;
94+
unsigned char value[];
95+
};
96+
97+
enum mrp_applications {
98+
MRP_APPLICATION_MVRP,
99+
__MRP_APPLICATION_MAX
100+
};
101+
#define MRP_APPLICATION_MAX (__MRP_APPLICATION_MAX - 1)
102+
103+
struct mrp_application {
104+
enum mrp_applications type;
105+
unsigned int maxattr;
106+
struct packet_type pkttype;
107+
unsigned char group_address[ETH_ALEN];
108+
u8 version;
109+
};
110+
111+
struct mrp_applicant {
112+
struct mrp_application *app;
113+
struct net_device *dev;
114+
struct timer_list join_timer;
115+
116+
spinlock_t lock;
117+
struct sk_buff_head queue;
118+
struct sk_buff *pdu;
119+
struct rb_root mad;
120+
struct rcu_head rcu;
121+
};
122+
123+
struct mrp_port {
124+
struct mrp_applicant __rcu *applicants[MRP_APPLICATION_MAX + 1];
125+
struct rcu_head rcu;
126+
};
127+
128+
extern int mrp_register_application(struct mrp_application *app);
129+
extern void mrp_unregister_application(struct mrp_application *app);
130+
131+
extern int mrp_init_applicant(struct net_device *dev,
132+
struct mrp_application *app);
133+
extern void mrp_uninit_applicant(struct net_device *dev,
134+
struct mrp_application *app);
135+
136+
extern int mrp_request_join(const struct net_device *dev,
137+
const struct mrp_application *app,
138+
const void *value, u8 len, u8 type);
139+
extern void mrp_request_leave(const struct net_device *dev,
140+
const struct mrp_application *app,
141+
const void *value, u8 len, u8 type);
142+
143+
#endif /* _NET_MRP_H */

‎net/802/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ config STP
55
config GARP
66
tristate
77
select STP
8+
9+
config MRP
10+
tristate

‎net/802/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ obj-$(CONFIG_IPX) += p8022.o psnap.o p8023.o
1111
obj-$(CONFIG_ATALK) += p8022.o psnap.o
1212
obj-$(CONFIG_STP) += stp.o
1313
obj-$(CONFIG_GARP) += garp.o
14+
obj-$(CONFIG_MRP) += mrp.o

0 commit comments

Comments
 (0)