Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106944715
D37088.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D37088.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -437,19 +437,8 @@
static inline int
kstrtou32(const char *cp, unsigned int base, u32 *res)
{
- char *end;
- unsigned long temp;
-
- *res = temp = strtoul(cp, &end, base);
- /* skip newline character, if any */
- if (*end == '\n')
- end++;
- if (*cp == 0 || *end != 0)
- return (-EINVAL);
- if (temp != (u32)temp)
- return (-ERANGE);
- return (0);
+ return (kstrtouint(cp, base, res));
}
static inline int
@@ -530,7 +519,7 @@
static inline int
kstrtouint_from_user(const char __user *s, size_t count, unsigned int base,
- int *p)
+ unsigned int *p)
{
char buf[36] = {};
@@ -543,6 +532,14 @@
return (kstrtouint(buf, base, p));
}
+static inline int
+kstrtou32_from_user(const char __user *s, size_t count, unsigned int base,
+ unsigned int *p)
+{
+
+ return (kstrtouint_from_user(s, count, base, p));
+}
+
static inline int
kstrtou8_from_user(const char __user *s, size_t count, unsigned int base,
u8 *p)
@@ -718,6 +715,48 @@
return (0);
}
+static inline bool
+mac_pton(const char *macin, uint8_t *macout)
+{
+ const char *s, *d;
+ uint8_t mac[6], hx, lx;;
+ int i;
+
+ if (strlen(macin) < (3 * 6 - 1))
+ return (false);
+
+ i = 0;
+ s = macin;
+ do {
+ /* Should we also support '-'-delimiters? */
+ d = strchrnul(s, ':');
+ hx = lx = 0;
+ while (s < d) {
+ /* Fail on abc:123:xxx:... */
+ if ((d - s) > 2)
+ return (false);
+ /* We do support non-well-formed strings: 3:45:6:... */
+ if ((d - s) > 1) {
+ hx = _h2b(*s);
+ if (hx < 0)
+ return (false);
+ s++;
+ }
+ lx = _h2b(*s);
+ if (lx < 0)
+ return (false);
+ s++;
+ }
+ mac[i] = (hx << 4) | lx;
+ i++;
+ if (i >= 6)
+ return (false);
+ } while (d != NULL && *d != '\0');
+
+ memcpy(macout, mac, 6);
+ return (true);
+}
+
#define DECLARE_FLEX_ARRAY(_t, _n) \
struct { struct { } __dummy_ ## _n; _t _n[0]; }
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 8:49 PM (2 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15726553
Default Alt Text
D37088.diff (2 KB)
Attached To
Mode
D37088: LinuxKPI: add kstrtou32_from_user() and mac_pton()
Attached
Detach File
Event Timeline
Log In to Comment