Skip to content

Commit

Permalink
Process sandesh decode errors
Browse files Browse the repository at this point in the history
If an incoming sandesh message is not decoded by the sandesh library
(because of some internal bugs/failures), such a failure needs to be
communicated to agent.

We now check for return value from sandesh decode and if the return
value indicates a sandesh decode failure, we return from netlink
'doit' with that error, which gets passed up to the application.

Change-Id: I39b2621a4ce89750160b7fac105ac2ecd24e60e0
Partial-BUG: #1466607
  • Loading branch information
anandhk-juniper committed Jul 28, 2015
1 parent 25937c8 commit b93b3d9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
7 changes: 6 additions & 1 deletion dp-core/vr_message.c
Expand Up @@ -53,6 +53,8 @@ vr_mtrans_free(void *buf)
int
vr_message_request(struct vr_message *message)
{
int ret;

if (!message_h.vm_proto)
return 0;

Expand All @@ -66,8 +68,11 @@ vr_message_request(struct vr_message *message)
return -EBADFD;
#endif

message_h.vm_proto->mproto_decode(message->vr_message_buf,
ret = message_h.vm_proto->mproto_decode(message->vr_message_buf,
message->vr_message_len, NULL, NULL);
if (ret < 0)
return ret;

return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions dp-core/vr_sandesh.c
Expand Up @@ -129,8 +129,8 @@ sandesh_proto_decode(char *buf, unsigned int len,
{
int ret = 0;

sandesh_decode((unsigned char *)buf, len, vr_find_sandesh_info, &ret);
return ret;
return sandesh_decode((unsigned char *)buf, len,
vr_find_sandesh_info, &ret);
}

static struct vr_mproto sandesh_mproto = {
Expand Down
6 changes: 5 additions & 1 deletion dpdk/vr_dpdk_netlink.c
Expand Up @@ -84,11 +84,15 @@ int
dpdk_netlink_receive(void *usockp, char *nl_buf,
unsigned int nl_len)
{
int ret;
struct vr_message request;

request.vr_message_buf = nl_buf + HDR_LEN;
request.vr_message_len = nl_len - HDR_LEN;
vr_message_request(&request);

ret = vr_message_request(&request);
if (ret < 0)
vr_send_response(ret);

dpdk_nl_process_response(usockp, (struct nlmsghdr *)nl_buf);

Expand Down
8 changes: 7 additions & 1 deletion linux/vr_genetlink.c
Expand Up @@ -17,6 +17,7 @@
#include "vr_types.h"
#include "vr_message.h"
#include "sandesh.h"
#include "vr_response.h"

static int netlink_trans_request(struct sk_buff *, struct genl_info *);

Expand Down Expand Up @@ -81,6 +82,7 @@ static int
netlink_trans_request(struct sk_buff *in_skb, struct genl_info *info)
{
char *buf;
int ret;
unsigned int len;
uint32_t multi_flag;
struct nlmsghdr *rep, *nlh = info->nlhdr;
Expand All @@ -97,7 +99,11 @@ netlink_trans_request(struct sk_buff *in_skb, struct genl_info *info)
request.vr_message_buf = nla_data(nla);
request.vr_message_len = nla_len(nla);

vr_message_request(&request);
ret = vr_message_request(&request);
if (ret < 0) {
if (vr_send_response(ret))
return ret;
}

#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
netlink_id = NETLINK_CB(in_skb).pid;
Expand Down

0 comments on commit b93b3d9

Please sign in to comment.