Skip to content

Commit d115da8

Browse files
Sairam Venugopalshettyg
authored andcommitted
datapath-windows: Add new NlFillOvsMsgForNfGenMsg method in Netlink.c
Create a new method to create and fill OvsMessage with NfGenMsg. This will be used for sending Netfilter based Netlink messages. Signed-off-by: Sairam Venugopal <vsairam@vmware.com> Acked-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
1 parent 9f8407b commit d115da8

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

datapath-windows/ovsext/Netlink/Netlink.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,45 @@ NlFillOvsMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
7171
return writeOk;
7272
}
7373

74+
/*
75+
* ---------------------------------------------------------------------------
76+
* Prepare netlink message headers. This API adds
77+
* NL_MSG_HDR + GENL_HDR + OVS_HDR to the tail of input NLBuf.
78+
* Attributes should be added by caller.
79+
* ---------------------------------------------------------------------------
80+
*/
81+
BOOLEAN
82+
NlFillOvsMsgForNfGenMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
83+
UINT16 nlmsgFlags, UINT32 nlmsgSeq,
84+
UINT32 nlmsgPid, UINT8 nfgenFamily,
85+
UINT8 nfGenVersion, UINT32 dpNo)
86+
{
87+
BOOLEAN writeOk;
88+
OVS_MESSAGE msgOut;
89+
UINT32 offset = NlBufSize(nlBuf);
90+
91+
/* To keep compiler happy for release build. */
92+
UNREFERENCED_PARAMETER(offset);
93+
ASSERT(NlBufAt(nlBuf, offset, 0) != 0);
94+
95+
msgOut.nlMsg.nlmsgType = nlmsgType;
96+
msgOut.nlMsg.nlmsgFlags = nlmsgFlags;
97+
msgOut.nlMsg.nlmsgSeq = nlmsgSeq;
98+
msgOut.nlMsg.nlmsgPid = nlmsgPid;
99+
msgOut.nlMsg.nlmsgLen = sizeof(struct _OVS_MESSAGE);
100+
101+
msgOut.nfGenMsg.nfgenFamily = nfgenFamily;
102+
msgOut.nfGenMsg.version = nfGenVersion;
103+
msgOut.nfGenMsg.resId = 0;
104+
105+
msgOut.ovsHdr.dp_ifindex = dpNo;
106+
107+
writeOk = NlMsgPutTail(nlBuf, (PCHAR)(&msgOut),
108+
sizeof (struct _OVS_MESSAGE));
109+
110+
return writeOk;
111+
}
112+
74113
/*
75114
* ---------------------------------------------------------------------------
76115
* Prepare NL_MSG_HDR only. This API appends a NL_MSG_HDR to the tail of

datapath-windows/ovsext/Netlink/Netlink.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ BOOLEAN NlFillOvsMsg(PNL_BUFFER nlBuf,
9595
UINT16 nlmsgType, UINT16 nlmsgFlags,
9696
UINT32 nlmsgSeq, UINT32 nlmsgPid,
9797
UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo);
98+
BOOLEAN NlFillOvsMsgForNfGenMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
99+
UINT16 nlmsgFlags, UINT32 nlmsgSeq,
100+
UINT32 nlmsgPid, UINT8 nfgenFamily,
101+
UINT8 nfGenVersion, UINT32 dpNo);
98102
BOOLEAN NlFillNlHdr(PNL_BUFFER nlBuf,
99103
UINT16 nlmsgType, UINT16 nlmsgFlags,
100104
UINT32 nlmsgSeq, UINT32 nlmsgPid);

0 commit comments

Comments
 (0)