forked from sonic-net/sonic-swss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteamsync.h
66 lines (55 loc) · 1.7 KB
/
teamsync.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef __TEAMSYNC__
#define __TEAMSYNC__
#include <map>
#include <string>
#include <memory>
#include "dbconnector.h"
#include "producerstatetable.h"
#include "selectable.h"
#include "select.h"
#include "netmsg.h"
#include <team.h>
namespace swss {
class TeamSync : public NetMsg
{
public:
TeamSync(DBConnector *db, DBConnector *stateDb, Select *select);
/*
* Listens to RTM_NEWLINK and RTM_DELLINK to undestand if there is a new
* team device
*/
virtual void onMsg(int nlmsg_type, struct nl_object *obj);
class TeamPortSync : public Selectable
{
public:
enum { MAX_IFNAME = 64 };
TeamPortSync(const std::string &lagName, int ifindex,
ProducerStateTable *lagMemberTable);
~TeamPortSync();
int getFd() override;
void readData() override;
protected:
int onChange();
static int teamdHandler(struct team_handle *th, void *arg,
team_change_type_mask_t type_mask);
static const struct team_change_handler gPortChangeHandler;
private:
ProducerStateTable *m_lagMemberTable;
struct team_handle *m_team;
std::string m_lagName;
int m_ifindex;
std::map<std::string, bool> m_lagMembers; /* map[ifname] = status (enabled|disabled) */
};
protected:
void addLag(const std::string &lagName, int ifindex, bool admin_state,
bool oper_state, unsigned int mtu);
void removeLag(const std::string &lagName);
private:
Select *m_select;
ProducerStateTable m_lagTable;
ProducerStateTable m_lagMemberTable;
Table m_stateLagTable;
std::map<std::string, std::shared_ptr<TeamPortSync> > m_teamPorts;
};
}
#endif