summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDewey Lee <dewey.lee@broadcom.corp-partner.google.com>2022-03-08 17:41:53 +0900
committerRoger Wang <wangroger@google.com>2022-03-14 15:48:01 +0000
commit44c8ee35901a9579054da283bf4dfbf21fda15f5 (patch)
tree973c3fc330ced2544745e2c17e8b7766d5767477
parent482143b8af3a746426cf66c82d15b8a9250373cf (diff)
downloadbcm4389-android-gs-raviole-5.10-s-qpr3-beta-2.tar.gz
bcmdhd: Fixed dump dhcp packets by adding exceptionandroid-s-qpr3-beta-2_r0.5android-gs-raviole-5.10-s-qpr3-beta-2
Basically, DHD dumps DHCP packets with default types. Types that DHD dumps DHCP packets as default: - DISCOVER, OFFER, REQUEST, DECLINE, ACK, NAK, RELEASE, INFORM However, if AP sends dhcp packets with another types, crash has been occured by over boundary. So, exception for other types is added to DHD. Bug: 222853182 Test: Tested it with P21 device Signed-off-by: Dewey Lee <dewey.lee@broadcom.corp-partner.google.com> Change-Id: Ic80ffdfdcc933d1504cb9883262c1c21670aa6c6
-rwxr-xr-xdhd_linux_pktdump.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/dhd_linux_pktdump.c b/dhd_linux_pktdump.c
index 9ed8ed1..e1d4809 100755
--- a/dhd_linux_pktdump.c
+++ b/dhd_linux_pktdump.c
@@ -922,16 +922,27 @@ typedef struct bootp_fmt {
uint8 options[BOOTP_MIN_DHCP_OPT_LEN];
} PACKED_STRUCT bootp_fmt_t;
+#define MAX_DHCP_OPS_STR 3
+#define MAX_DHCP_TYPES_STR 9
+
static const uint8 bootp_magic_cookie[4] = { 99, 130, 83, 99 };
-static char dhcp_ops[][10] = {
+static char dhcp_ops[MAX_DHCP_OPS_STR][10] = {
"NA", "REQUEST", "REPLY"
};
-static char dhcp_types[][10] = {
+static char dhcp_types[MAX_DHCP_TYPES_STR][10] = {
"NA", "DISCOVER", "OFFER", "REQUEST", "DECLINE", "ACK", "NAK", "RELEASE", "INFORM"
};
+#define DHCP_OPS_STR(ops) ((ops < MAX_DHCP_OPS_STR) ? \
+ (dhcp_ops[ops]) : "UNKNOWN_DHCP_OPS")
+#define DHCP_TYPES_STR(type) ((type < MAX_DHCP_TYPES_STR) ? \
+ (dhcp_types[type]) : "UNKNOWN_DHCP_TYPE")
+
#ifdef DHD_STATUS_LOGGING
-static const int dhcp_types_stat[9] = {
+#define MAX_DHCP_TYPES_STAT 9
+#define DHCP_TYPES_STAT(type) ((type < MAX_DHCP_TYPES_STAT) ? \
+ (dhcp_types_stat[type]) : ST(INVALID))
+static const int dhcp_types_stat[MAX_DHCP_TYPES_STAT] = {
ST(INVALID), ST(DHCP_DISCOVER), ST(DHCP_OFFER), ST(DHCP_REQUEST),
ST(DHCP_DECLINE), ST(DHCP_ACK), ST(DHCP_NAK), ST(DHCP_RELEASE),
ST(DHCP_INFORM)
@@ -944,7 +955,8 @@ dhd_dhcp_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx,
{
bootp_fmt_t *b = (bootp_fmt_t *)&pktdata[ETHER_HDR_LEN];
uint8 *ptr, *opt, *end = (uint8 *) b + ntohs(b->iph.tot_len);
- int dhcp_type = 0, len, opt_len;
+ uint8 dhcp_type = 0;
+ int len, opt_len;
char *ifname = NULL, *typestr = NULL, *opstr = NULL;
bool cond;
@@ -970,9 +982,9 @@ dhd_dhcp_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx,
if (*opt == DHCP_OPT_MSGTYPE) {
if (opt[1]) {
dhcp_type = opt[2];
- typestr = dhcp_types[dhcp_type];
- opstr = dhcp_ops[b->op];
- DHD_STATLOG_DATA(dhdp, dhcp_types_stat[dhcp_type],
+ typestr = DHCP_TYPES_STR(dhcp_type);
+ opstr = DHCP_OPS_STR(b->op);
+ DHD_STATLOG_DATA(dhdp, DHCP_TYPES_STAT(dhcp_type),
ifidx, tx, cond);
DHCP_PRINT("DHCP");
break;