Commit 3a3ef679 authored by Alessandro Rubini's avatar Alessandro Rubini

general: use PP_RECV_DROP and PP_SEND_DROP instead of "-2"

It was a hack of mine, I'd better call it by name. We must spit
no errors when injecting faults.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 75707f6a
...@@ -107,7 +107,7 @@ void unix_main_loop(struct pp_globals *ppg) ...@@ -107,7 +107,7 @@ void unix_main_loop(struct pp_globals *ppg)
PP_MAX_FRAME_LENGTH - 4, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
if (i == -2) { if (i == PP_RECV_DROP) {
continue; /* dropped or not for us */ continue; /* dropped or not for us */
} }
if (i == -1) { if (i == -1) {
......
...@@ -148,7 +148,7 @@ void wrs_main_loop(struct pp_globals *ppg) ...@@ -148,7 +148,7 @@ void wrs_main_loop(struct pp_globals *ppg)
PP_MAX_FRAME_LENGTH - 4, PP_MAX_FRAME_LENGTH - 4,
&ppi->last_rcv_time); &ppi->last_rcv_time);
if (i == -2) { if (i == PP_RECV_DROP) {
continue; /* dropped or not for us */ continue; /* dropped or not for us */
} }
if (i == -1) { if (i == -1) {
......
...@@ -381,6 +381,8 @@ extern void msg_unpack_pdelay_req(void *buf, MsgPDelayReq * pdelay_req); ...@@ -381,6 +381,8 @@ extern void msg_unpack_pdelay_req(void *buf, MsgPDelayReq * pdelay_req);
#define PP_SEND_OK 0 #define PP_SEND_OK 0
#define PP_SEND_ERROR -1 #define PP_SEND_ERROR -1
#define PP_SEND_NO_STAMP 1 #define PP_SEND_NO_STAMP 1
#define PP_SEND_DROP -2
#define PP_RECV_DROP PP_SEND_DROP
extern void *msg_copy_header(MsgHeader *dest, MsgHeader *src); /* REMOVE ME!! */ extern void *msg_copy_header(MsgHeader *dest, MsgHeader *src); /* REMOVE ME!! */
extern int msg_issue_announce(struct pp_instance *ppi); extern int msg_issue_announce(struct pp_instance *ppi);
......
...@@ -66,7 +66,7 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -66,7 +66,7 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
/* If we are in VLAN mode, we get everything. This is ok */ /* If we are in VLAN mode, we get everything. This is ok */
if (ppi->proto != PPSI_PROTO_VLAN) if (ppi->proto != PPSI_PROTO_VLAN)
pp_error("%s: truncated message\n", __func__); pp_error("%s: truncated message\n", __func__);
return -2; /* like "dropped" */ return PP_RECV_DROP; /* like "dropped" */
} }
/* get time stamp of packet */ /* get time stamp of packet */
if (msg.msg_flags & MSG_CTRUNC) { if (msg.msg_flags & MSG_CTRUNC) {
...@@ -102,13 +102,13 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -102,13 +102,13 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
if (aux) { if (aux) {
/* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */ /* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */
if (hdr->h_proto != htons(ETH_P_1588)) if (hdr->h_proto != htons(ETH_P_1588))
return -2; /* like "dropped", so no error message */ return PP_RECV_DROP; /* no error message */
/* Also, we got the vlan, and we can discard it if not ours */ /* Also, we got the vlan, and we can discard it if not ours */
for (i = 0; i < ppi->nvlans; i++) for (i = 0; i < ppi->nvlans; i++)
if (ppi->vlans[i] == (aux->tp_vlan_tci & 0xfff)) if (ppi->vlans[i] == (aux->tp_vlan_tci & 0xfff))
break; /* ok */ break; /* ok */
if (i == ppi->nvlans) if (i == ppi->nvlans)
return -2; /* not ours: say it's dropped */ return PP_RECV_DROP; /* not ours: say it's dropped */
ppi->peer_vid = ppi->vlans[i]; ppi->peer_vid = ppi->vlans[i];
} else { } else {
ppi->peer_vid = 0; ppi->peer_vid = 0;
...@@ -116,7 +116,7 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -116,7 +116,7 @@ static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
if (ppsi_drop_rx()) { if (ppsi_drop_rx()) {
pp_diag(ppi, frames, 1, "Drop received frame\n"); pp_diag(ppi, frames, 1, "Drop received frame\n");
return -2; return PP_RECV_DROP;
} }
/* This is not really hw... */ /* This is not really hw... */
...@@ -143,7 +143,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -143,7 +143,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
if (ret <= 0) if (ret <= 0)
return ret; return ret;
if (hdr->h_proto != htons(ETH_P_1588)) if (hdr->h_proto != htons(ETH_P_1588))
return -2; /* like "dropped", so no error message */ return PP_RECV_DROP; /* like "dropped", so no error message */
memcpy(ppi->peer, hdr->h_source, ETH_ALEN); memcpy(ppi->peer, hdr->h_source, ETH_ALEN);
if (pp_diag_allow(ppi, frames, 2)) { if (pp_diag_allow(ppi, frames, 2)) {
......
...@@ -80,7 +80,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -80,7 +80,7 @@ static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
if (CONFIG_HAS_WRPC_FAULTS && ppsi_drop_rx()) { if (CONFIG_HAS_WRPC_FAULTS && ppsi_drop_rx()) {
pp_diag(ppi, frames, 1, "Drop received frame\n"); pp_diag(ppi, frames, 1, "Drop received frame\n");
return -2; return PP_RECV_DROP;
} }
if (CONFIG_HAS_WRPC_FAULTS) if (CONFIG_HAS_WRPC_FAULTS)
...@@ -133,7 +133,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -133,7 +133,7 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
} }
if (CONFIG_HAS_WRPC_FAULTS && drop) { if (CONFIG_HAS_WRPC_FAULTS && drop) {
pp_diag(ppi, frames, 1, "Drop sent frame\n"); pp_diag(ppi, frames, 1, "Drop sent frame\n");
return -2; return PP_SEND_DROP;
} }
/* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */ /* wrpc-sw may pass this in USER_CFLAGS, to remove footprint */
......
...@@ -274,25 +274,25 @@ drop: ...@@ -274,25 +274,25 @@ drop:
/* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */ /* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */
if (hdr->h_proto != htons(ETH_P_1588)) if (hdr->h_proto != htons(ETH_P_1588))
return -2; /* like "dropped", so no error message */ return PP_RECV_DROP; /* no error message */
/* Also, we got the vlan, and we can discard it if not ours */ /* Also, we got the vlan, and we can discard it if not ours */
for (i = 0; i < ppi->nvlans; i++) for (i = 0; i < ppi->nvlans; i++)
if (ppi->vlans[i] == vlan) if (ppi->vlans[i] == vlan)
break; /* ok */ break; /* ok */
if (i == ppi->nvlans) if (i == ppi->nvlans)
return -2; /* not ours: say it's dropped */ return PP_RECV_DROP; /* not ours: say it's dropped */
ppi->peer_vid = ppi->vlans[i]; ppi->peer_vid = ppi->vlans[i];
} else { } else {
if (hdr->h_proto != htons(ETH_P_1588)) if (hdr->h_proto != htons(ETH_P_1588))
return -2; /* again: drop unrelated frames */ return PP_RECV_DROP; /* again: drop unrelated frames */
ppi->peer_vid = 0; ppi->peer_vid = 0;
} }
out: out:
if (ppsi_drop_rx()) { if (ppsi_drop_rx()) {
pp_diag(ppi, frames, 1, "Drop received frame\n"); pp_diag(ppi, frames, 1, "Drop received frame\n");
return -2; return PP_RECV_DROP;
} }
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment