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-21 08:19:00 +0000
commiteb31a351f43692bc1cb8ad45248780da5fcaadab (patch)
treeb02b37288cb1962171d918bd561d9ae5d67e1df5
parentc275b95b65eb42340c50f228d42f5d9274c7ae07 (diff)
downloadbcm4389-android-gs-bluejay-5.10-android12L-d2.tar.gz
bcmdhd: Fixed dump dhcp packets by adding exceptionandroid-12.1.0_r0.40android-gs-bluejay-5.10-android12L-d2
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: 225505816 Test: Tested it with P21 device Signed-off-by: Dewey Lee <dewey.lee@broadcom.corp-partner.google.com> Change-Id: Ic80ffdfdcc933d1504cb9883262c1c21670aa6c6 (cherry picked from commit 35bd7c3d5a95239f1816217c6f5234d955e18e56)
-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;