[OpenWrt-Devel] D-Link switches with GPL Linux kernel available
Dear all, First I would like to congratulate the community for working hard on OpenWRT. For years I have been using pfSense and now that they are closing sources (aka on copyright issues) and compiling without peer review, I am turning towards OpenWRT. I am impressed by the quality of OpenWRT project. I like the ability to compile firmwares ourselves. After migrating to OpenWRT on routers, I would like to give a try at switches. [This is a cross post on the forum, sorry]: D-Link published the GPL source code of its main router line (for individuals and small companies), which is the DGS-1210 line. It includes Gigabyte routers from 8 to 48 ports, with SPF connectors and advanced features. Those switches can be purchased for a low pricing on eBay. Example : 48 port switch for 70,00 GBP (around 98 EUR). One reason is that D-Linked never updated the firmware between hardware revision A, B, C and D. So most old switches only support IPv4 and people are massively reselling them for IPv6 compliance (and buying new ones to D-Link, is that what D-Link wants?). This may be an opportunity for OpenWRT and us hackers. All switches are running Linux. Source code is available here : http://tsd.dlink.com.tw/downloads2008detail.asp Scroll down and display lines with "GPL source code". And the click on a model, and download source code. Example: DGS-1210-10P revision A1 and A2 source code : https://dlink-gpl.s3.amazonaws.com/GPL1200117/DGS-1210-10P-GPLSourceCode.tar.gz A script allows to compile a firmware image. Do you think this is the complete source code or are some drivers not published and missing? Could you have a quick look at the source code and tell your opinion? On my side I am trying to access the console, but no luck until now. Some GPIOs are used by LED display and I have a hard time finding serial PINs. Kind regards, Gnutella ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] D-Link switches with GPL Linux kernel available
Sorry, source code is available here : http://tsd.dlink.com.tw Select DGS and 1210 and click OK. ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] D-Link switches with GPL Linux kernel available
Dear friends, I downloaded D-Link DGS-1210-10P switch latest GPL source code, hardware rev C1 (latest revision to date, available in shops): https://dlink-gpl.s3.amazonaws.com/GPL1500075/DGS-1210-10P-GPLSourceCode.tar.gz Compilation instructions: https://dlink-gpl.s3.amazonaws.com/GPL1500075/readme.txt I could find the .config file in : DGS-1210-10P-GPL/os/linux-3.6.5_iProLDK_3.3.1/broadcom.config/hurricane2 This seems completely open-source, can you confirm. Here is the .config file for those interested. Do you think it could be adapted to OpenWRT? Kind regards, Gnutella *** here is the .config file # # Automatically generated file; DO NOT EDIT. # Linux/arm 3.6.5 Kernel Configuration # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y CONFIG_GENERIC_GPIO=y CONFIG_HAVE_PROC_CPU=y CONFIG_STACKTRACE_SUPPORT=y CONFIG_LOCKDEP_SUPPORT=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y CONFIG_RWSEM_GENERIC_SPINLOCK=y CONFIG_GENERIC_HWEIGHT=y CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_VECTORS_BASE=0x CONFIG_ARM_PATCH_PHYS_VIRT=y CONFIG_GENERIC_BUG=y CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" CONFIG_HAVE_IRQ_WORK=y # # General setup # CONFIG_EXPERIMENTAL=y CONFIG_INIT_ENV_ARG_LIMIT=32 CONFIG_CROSS_COMPILE="$CROSS_COMPILE" CONFIG_LOCALVERSION="'-Broadcom Linux'" CONFIG_LOCALVERSION_AUTO=y CONFIG_HAVE_KERNEL_GZIP=y CONFIG_HAVE_KERNEL_LZMA=y CONFIG_HAVE_KERNEL_XZ=y CONFIG_HAVE_KERNEL_LZO=y CONFIG_KERNEL_GZIP=y # CONFIG_KERNEL_LZMA is not set # CONFIG_KERNEL_XZ is not set # CONFIG_KERNEL_LZO is not set CONFIG_DEFAULT_HOSTNAME="(none)" # CONFIG_SWAP is not set CONFIG_SYSVIPC=y CONFIG_SYSVIPC_SYSCTL=y # CONFIG_POSIX_MQUEUE is not set # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_FHANDLE is not set # CONFIG_TASKSTATS is not set # CONFIG_AUDIT is not set CONFIG_HAVE_GENERIC_HARDIRQS=y # # IRQ subsystem # CONFIG_GENERIC_HARDIRQS=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_GENERIC_IRQ_SHOW=y CONFIG_HARDIRQS_SW_RESEND=y CONFIG_IRQ_DOMAIN=y CONFIG_KTIME_SCALAR=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_GENERIC_CLOCKEVENTS_BUILD=y CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y # # Timers subsystem # CONFIG_TICK_ONESHOT=y CONFIG_NO_HZ=y # CONFIG_HIGH_RES_TIMERS is not set # # RCU Subsystem # CONFIG_TREE_RCU=y # CONFIG_PREEMPT_RCU is not set CONFIG_RCU_FANOUT=32 CONFIG_RCU_FANOUT_LEAF=16 # CONFIG_RCU_FANOUT_EXACT is not set # CONFIG_RCU_FAST_NO_HZ is not set # CONFIG_TREE_RCU_TRACE is not set CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=14 # CONFIG_CHECKPOINT_RESTORE is not set # CONFIG_NAMESPACES is not set # CONFIG_SCHED_AUTOGROUP is not set # CONFIG_SYSFS_DEPRECATED is not set # CONFIG_RELAY is not set # CONFIG_BLK_DEV_INITRD is not set # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set CONFIG_SYSCTL=y CONFIG_EXPERT=y CONFIG_UID16=y CONFIG_SYSCTL_SYSCALL=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_ALL is not set CONFIG_HOTPLUG=y CONFIG_PRINTK=y CONFIG_BUG=y # CONFIG_ELF_CORE is not set # CONFIG_BASE_FULL is not set CONFIG_FUTEX=y # CONFIG_EPOLL is not set # CONFIG_SIGNALFD is not set # CONFIG_TIMERFD is not set # CONFIG_EVENTFD is not set # CONFIG_SHMEM is not set # CONFIG_AIO is not set CONFIG_EMBEDDED=y CONFIG_HAVE_PERF_EVENTS=y CONFIG_PERF_USE_VMALLOC=y # # Kernel Performance Events And Counters # # CONFIG_PERF_EVENTS is not set CONFIG_VM_EVENT_COUNTERS=y CONFIG_PCI_QUIRKS=y # CONFIG_SLUB_DEBUG is not set # CONFIG_COMPAT_BRK is not set # CONFIG_SLAB is not set CONFIG_SLUB=y # CONFIG_SLOB is not set # CONFIG_PROFILING is not set CONFIG_HAVE_OPROFILE=y # CONFIG_KPROBES is not set # CONFIG_JUMP_LABEL is not set CONFIG_HAVE_KPROBES=y CONFIG_HAVE_KRETPROBES=y CONFIG_HAVE_ARCH_TRACEHOOK=y CONFIG_HAVE_DMA_ATTRS=y CONFIG_HAVE_DMA_CONTIGUOUS=y CONFIG_USE_GENERIC_SMP_HELPERS=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y CONFIG_HAVE_CLK=y CONFIG_HAVE_DMA_API_DEBUG=y CONFIG_HAVE_ARCH_JUMP_LABEL=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y # # GCOV-based kernel profiling # CONFIG_HAVE_GENERIC_DMA_COHERENT=y CONFIG_RT_MUTEXES=y CONFIG_BASE_SMALL=1 CONFIG_MODULES=y # CONFIG_MODULE_FORCE_LOAD is not set CONFIG_MODULE_UNLOAD=y # CONFIG_MODULE_FORCE_UNLOAD is not set # CONFIG_MODVERSIONS is not set # CONFIG_MODULE_SRCVERSION_ALL is not set CONFIG_STOP_MACHINE=y CONFIG_BLOCK=y CONFIG_LBDAF=y CONFIG_BLK_DEV_BSG=y # CONFIG_BLK_DEV_BSGLIB is not set # CONFIG_BLK_DEV_INTEGRITY is not set # # Partition Types # CONFIG_PARTITION_ADVANCED=y # CONFIG_ACORN_PARTITION is not set # CONFIG_OSF_PARTITION is not set # CONFIG_AMIGA_PARTITION is not set # CONFIG_ATARI_PARTITION is not set # CONFIG_MAC_PARTITION is not set CONFIG_MSDOS_PARTITION=y # CONFIG_BSD_DISKLABEL is not set # CONFIG_MINIX_SUBPARTITION is not set # CONFIG_SOLARIS_X86_PARTITION is not set # CONFIG_UNIXWARE_DISKLABEL is not set # CONFIG_LDM_PARTITION is not set # CONFIG_SGI_PARTITION is not set # CONFIG_ULTRIX_PARTITION is not set # CONFIG_SUN_PARTITION is not set # CONFIG_KARMA_PARTITION is not set # CONFIG_EFI_PARTITION
[OpenWrt-Devel] [PATCH v2] x86: use PARTUUID instead explicitly specifying the device by default
This changes the x86 image generation to match x86_64, using the PARTUUID for the rootfs instead of explicitly configuring the device. It unbreaks KVM with VirtIO, which uses /dev/vda2 instead of /dev/sda2. Tested in QEMU/KVM with VirtIO, VirtualBox and VMware. Signed-off-by: Matthias Schiffer --- v2: fix sysupgrade by also changing the base-files to match the x86_64 version config/Config-images.in| 2 - .../x86/base-files/lib/preinit/79_move_config | 21 +++ .../linux/x86/base-files/lib/upgrade/platform.sh | 70 ++ target/linux/x86/image/Makefile| 4 +- target/linux/x86/image/gen_image_generic.sh| 2 +- 5 files changed, 57 insertions(+), 42 deletions(-) diff --git a/config/Config-images.in b/config/Config-images.in index 5c2e79e..a420c39 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -267,8 +267,6 @@ menu "Target Images" config TARGET_ROOTFS_PARTNAME string "Root partition on target device" depends on OLPC_BOOTSCRIPT_IMAGES || GRUB_IMAGES - default "/dev/xvda2" if TARGET_x86_xen_domu - default "/dev/sda2" if TARGET_x86 && ! TARGET_x86_xen_domu help Override the root partition on the final device. If left empty, it will be mounted by PARTUUID which makes the kernel find the diff --git a/target/linux/x86/base-files/lib/preinit/79_move_config b/target/linux/x86/base-files/lib/preinit/79_move_config index 0bffbab..1d4873d 100644 --- a/target/linux/x86/base-files/lib/preinit/79_move_config +++ b/target/linux/x86/base-files/lib/preinit/79_move_config @@ -1,21 +1,14 @@ #!/bin/sh -# Copyright (C) 2012 OpenWrt.org +# Copyright (C) 2012-2015 OpenWrt.org move_config() { - local rootfsdev - local rootfstype - - rootfstype="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "rootfstype") { print $2 }' < /proc/cmdline)" - case "$rootfstype" in - squashfs|jffs2) - rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)";; - ext4) - rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)";; - esac + . /lib/upgrade/platform.sh - mount -t ext4 -o rw,noatime "${rootfsdev%[0-9]}1" /mnt - mv -f /mnt/sysupgrade.tgz / - umount /mnt + if platform_export_bootpart; then + mount -t ext4 -o rw,noatime "$BOOTPART" /mnt + mv -f /mnt/sysupgrade.tgz / + umount /mnt + fi } boot_hook_add preinit_mount_root move_config diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index a2dd20a..73ab5ef 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -1,16 +1,38 @@ -x86_get_rootfs() { - local rootfsdev - local rootfstype - - rootfstype="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "rootfstype") { print $2 }' < /proc/cmdline)" - case "$rootfstype" in - squashfs|jffs2) - rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)";; - ext4) - rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)";; - esac - - echo "$rootfstype:$rootfsdev" +platform_export_bootpart() { + local cmdline uuid disk + + if read cmdline < /proc/cmdline; then + case "$cmdline" in + *block2mtd=*) + disk="${cmdline##*block2mtd=}" + disk="${disk%%,*}" + ;; + *root=*) + disk="${cmdline##*root=}" + disk="${disk%% *}" + ;; + esac + + case "$disk" in + PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-02) + uuid="${disk#PARTUUID=}" + uuid="${uuid%-02}" + for disk in /dev/[hsv]d[a-z]; do + set -- $(dd if=$disk bs=1 skip=440 count=4 2>/dev/null | hexdump -v -e '4/1 "%02x "') + if [ "$4$3$2$1" = "$uuid" ]; then + export BOOTPART="${disk}1" + return 0 + fi + done + ;; + /dev/*) + expo
[OpenWrt-Devel] init scripts from files/etc/init.d/ are broken
Hi, init scripts placed in files/etc/init.d/ are not enabled anymore. This is probably caused by this change: https://dev.openwrt.org/changeset/42470 A workaround would be to enable init scripts in /etc/uci-defaults/. But this does not work because the list of executed scripts seem to be determined before the first init script is executed. So there seem to be two solutions: - enable init scripts in files/etc/init.d/ again - rescan the init scripts after each executed init script in case there have been changes Is there another option? regards, mwarning signature.asc Description: OpenPGP digital signature ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] Kind request to commit http://patchwork.ozlabs.org/patch/449868/
Greetings all! On thursday I provided this patch regarding the Hornet-UB board; the commit was accepted: http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=beed4d82d6a0154b0cd5f7b84e2180215ace6718 I ended up making a mistake on it though: changed the WPS LED related active_low value as well which I shouldn't have. I sent a patch for it here: http://patchwork.ozlabs.org/patch/449868/ Could blogic (who accepted the prev commit) or someone else someone kindly commit this small but significant change? Thank you :) Br, Janne Cederberg ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] Kind request to commit http://patchwork.ozlabs.org/patch/449868/
On 15/03/2015 20:18, Janne Cederberg wrote: > Greetings all! > On thursday I provided this patch regarding the Hornet-UB board; the > commit was accepted: > http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=beed4d82d6a0154b0cd5f7b84e2180215ace6718 > > I ended up making a mistake on it though: changed the WPS LED related > active_low value as well which I shouldn't have. I sent a patch for it > here: > http://patchwork.ozlabs.org/patch/449868/ > > Could blogic (who accepted the prev commit) or someone else someone > kindly commit this small but significant change? > only because you asked so nicely ;) > Thank you :) > > Br, Janne Cederberg > ___ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel > ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] kernel: Support kernel options required by systemd
On 12/03/2015 13:54, Jeff Waugh wrote: > +config KERNEL_FHANDLE > + bool "Compile the kernel with support for fhandle syscalls" > + default n > + Hi, support for fhandle was added in r44765 John ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3] [rpcd] file: add md5sum support
Signed-off-by: Luka Perkov --- file.c | 37 + 1 file changed, 37 insertions(+) diff --git a/file.c b/file.c index 31a937d..9e87a10 100644 --- a/file.c +++ b/file.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -237,6 +238,41 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, } static int +rpc_file_md5(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + int rv, i; + char *path; + struct stat s; + uint8_t md5[16]; + char *wbuf; + + if (!rpc_check_path(msg, &path, &s)) + return rpc_errno_status(); + + if (!S_ISREG(s.st_mode)) + return UBUS_STATUS_NOT_SUPPORTED; + + if ((rv = md5sum(path, md5)) <= 0) + return rpc_errno_status(); + + blob_buf_init(&buf, 0); + wbuf = blobmsg_alloc_string_buffer(&buf, "md5", 33); + + for (i = 0; i < 16; i++) + sprintf((wbuf + (i * 2)), "%02x", (uint8_t) md5[i]); + + *(wbuf + 33) = 0; + + blobmsg_add_string_buffer(&buf); + ubus_send_reply(ctx, req, buf.head); + blob_buf_free(&buf); + + return UBUS_STATUS_OK; +} + +static int rpc_file_list(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) @@ -611,6 +647,7 @@ rpc_file_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx) UBUS_METHOD("write", rpc_file_write, rpc_file_rw_policy), UBUS_METHOD("list",rpc_file_list, rpc_file_r_policy), UBUS_METHOD("stat",rpc_file_stat, rpc_file_r_policy), + UBUS_METHOD("md5", rpc_file_md5, rpc_file_r_policy), UBUS_METHOD("exec",rpc_file_exec, rpc_exec_policy), }; -- 2.3.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 2/3] [rpcd] file: add support for base64
b64encode and b64decode functions were taken from zstream project which was written by Steven Barth and John Crispin. Signed-off-by: Luka Perkov --- file.c | 197 + 1 file changed, 187 insertions(+), 10 deletions(-) diff --git a/file.c b/file.c index 9e87a10..54f5d8a 100644 --- a/file.c +++ b/file.c @@ -79,14 +79,27 @@ static const struct blobmsg_policy rpc_file_r_policy[__RPC_F_R_MAX] = { }; enum { + RPC_F_RB_PATH, + RPC_F_RB_BASE64, + __RPC_F_RB_MAX, +}; + +static const struct blobmsg_policy rpc_file_rb_policy[__RPC_F_RB_MAX] = { + [RPC_F_RB_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RB_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL }, +}; + +enum { RPC_F_RW_PATH, RPC_F_RW_DATA, + RPC_F_RW_BASE64, __RPC_F_RW_MAX, }; static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { - [RPC_F_RW_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, - [RPC_F_RW_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL }, }; enum { @@ -114,6 +127,122 @@ static const char *d_types[] = { }; +static const unsigned char b64encode_tbl[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +static char +*b64encode(const void *in, size_t *len) +{ + size_t lenout, pad, i; + const uint8_t *data = (const uint8_t *) in; + + lenout = *len / 3; + lenout *= 4; + pad = *len % 3; + + if (*len == 0) { + return strdup(""); + } else if (pad) { + lenout += 4; + } + + char *out = calloc(lenout + 1, sizeof(char)); + if (!out) + return NULL; + + uint8_t *o = (uint8_t*)out; + for (i = 0; i < *len; i += 3) { + uint32_t cv = (data[i] << 16) | (data[i+1] << 8) | data[i+2]; + *(o+3) = b64encode_tbl[ cv& 0x3f]; + *(o+2) = b64encode_tbl[(cv >> 6) & 0x3f]; + *(o+1) = b64encode_tbl[(cv >> 12) & 0x3f]; + *o = b64encode_tbl[(cv >> 18) & 0x3f]; + o += 4; + } + + if (pad) { + uint32_t cv = data[*len-pad] << 16; + *(o-1) = '='; + *(o-2) = '='; + if (pad == 2) { + cv |= data[*len-pad+1] << 8; + *(o-2) = b64encode_tbl[(cv >> 6) & 0x3f]; + } + *(o-3) = b64encode_tbl[(cv >> 12) & 0x3f]; + *(o-4) = b64encode_tbl[(cv >> 18) & 0x3f]; + } + + out[lenout] = 0; + *len = lenout; + return out; +} + +static const unsigned char b64decode_tbl[] = { + 0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36, + 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, + 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1b, + 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, + 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33 +}; + +static void +*b64decode(const char *in, size_t *len) +{ + size_t lenout, i; + + if (*len == 0) { + return strdup(""); + } else if (*len % 4) { + errno = EINVAL; + return NULL; + } + + lenout = *len / 4 * 3; + + unsigned char *out = calloc(lenout + 1, sizeof(char)); + if (!out) + return NULL; + + unsigned char *o = out; + for (i = 0; i < *len; i += 4) { + uint32_t cv = 0; + for (int j = 0; j < 4; j++) { + unsigned char c = in[i + j] - 43; + if (c > 79 || (c = b64decode_tbl[c]) == 0xff) { + free(out); + errno = EINVAL; + return NULL; + } + + cv |= c; + if (j != 3) { + cv <<= 6; + } + } + + *(o+2) = (unsigned char)(cv & 0xff); + *(o+1) = (unsigned char)((cv >> 8) & 0xff); + *o = (unsigned char)((cv >> 16) & 0xff); + o += 3; + } + + if (in[*len-1] == '=') { + lenout--; + } + + if (in[*len-2] == '=') { + lenout--; + } + + *len = lenout; + return out; +} + static int rpc_errno_status(void) { @@ -162,
[OpenWrt-Devel] [PATCH 3/3] [rpcd] file: add support for setting mode when writing files
Signed-off-by: Luka Perkov --- file.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index 54f5d8a..95dd4d4 100644 --- a/file.c +++ b/file.c @@ -92,6 +92,7 @@ static const struct blobmsg_policy rpc_file_rb_policy[__RPC_F_RB_MAX] = { enum { RPC_F_RW_PATH, RPC_F_RW_DATA, + RPC_F_RW_MODE, RPC_F_RW_BASE64, __RPC_F_RW_MAX, }; @@ -99,6 +100,7 @@ enum { static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { [RPC_F_RW_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, [RPC_F_RW_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_INT32 }, [RPC_F_RW_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL }, }; @@ -372,6 +374,7 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, { struct blob_attr *tb[__RPC_F_RW_MAX]; bool base64 = false; + mode_t mode = 0644; int fd, rv = 0; void *rbuf; size_t rbuf_len; @@ -382,12 +385,16 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, if (!tb[RPC_F_RW_PATH] || !tb[RPC_F_RW_DATA]) return UBUS_STATUS_INVALID_ARGUMENT; - if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | O_TRUNC)) < 0) - return rpc_errno_status(); + if (tb[RPC_F_RW_MODE]) + mode = blobmsg_get_u32(tb[RPC_F_RW_MODE]); if (tb[RPC_F_RW_BASE64]) base64 = blobmsg_get_bool(tb[RPC_F_RW_BASE64]); + umask(0); + if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | O_TRUNC, mode)) < 0) + return rpc_errno_status(); + if (base64) { rbuf_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; rbuf = b64decode(blobmsg_data(tb[RPC_F_RW_DATA]), &rbuf_len); -- 2.3.3 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] [rpcd] file: add md5sum support
Hi, On 15/03/2015 22:00, Luka Perkov wrote: > wbuf = blobmsg_alloc_string_buffer(&buf, "md5", 33); > + > + for (i = 0; i < 16; i++) > + sprintf((wbuf + (i * 2)), "%02x", (uint8_t) md5[i]); there is a set of brackets too many here > + > + *(wbuf + 33) = 0; is this not off by 1 ? if we want to be pedantic it should also be '\0' i think wbuf[32] = '\0'; is a saner syntax John ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 2/3] [rpcd] file: add support for base64
On 15/03/2015 22:00, Luka Perkov wrote: > b64encode and b64decode functions were taken from zstream project which was > written by Steven Barth and John Crispin. > i did not write this :) > Signed-off-by: Luka Perkov > --- > file.c | 197 > + > 1 file changed, 187 insertions(+), 10 deletions(-) > > diff --git a/file.c b/file.c > index 9e87a10..54f5d8a 100644 > --- a/file.c > +++ b/file.c > @@ -79,14 +79,27 @@ static const struct blobmsg_policy > rpc_file_r_policy[__RPC_F_R_MAX] = { > }; > > enum { > + RPC_F_RB_PATH, > + RPC_F_RB_BASE64, > + __RPC_F_RB_MAX, > +}; > + > +static const struct blobmsg_policy rpc_file_rb_policy[__RPC_F_RB_MAX] = { > + [RPC_F_RB_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, > + [RPC_F_RB_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL }, > +}; > + > +enum { > RPC_F_RW_PATH, > RPC_F_RW_DATA, > + RPC_F_RW_BASE64, > __RPC_F_RW_MAX, > }; > > static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { > - [RPC_F_RW_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, > - [RPC_F_RW_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING }, > + [RPC_F_RW_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, > + [RPC_F_RW_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING }, > + [RPC_F_RW_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL }, > }; > > enum { > @@ -114,6 +127,122 @@ static const char *d_types[] = { > }; > > > +static const unsigned char b64encode_tbl[] = > + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; > + > +static char > +*b64encode(const void *in, size_t *len) > +{ > + size_t lenout, pad, i; > + const uint8_t *data = (const uint8_t *) in; > + > + lenout = *len / 3; > + lenout *= 4; > + pad = *len % 3; > + > + if (*len == 0) { > + return strdup(""); > + } else if (pad) { > + lenout += 4; > + } no need for brackets here > + > + char *out = calloc(lenout + 1, sizeof(char)); char *out; should eb at the start of the function. > + if (!out) > + return NULL; > + > + uint8_t *o = (uint8_t*)out; missing space here ^ > + for (i = 0; i < *len; i += 3) { > + uint32_t cv = (data[i] << 16) | (data[i+1] << 8) | data[i+2]; > + *(o+3) = b64encode_tbl[ cv& 0x3f]; > + *(o+2) = b64encode_tbl[(cv >> 6) & 0x3f]; > + *(o+1) = b64encode_tbl[(cv >> 12) & 0x3f]; > + *o = b64encode_tbl[(cv >> 18) & 0x3f]; > + o += 4; the *(x) syntax is wonky imho. this should be changed to o[x] and there are missing spaces here aswell > + } > + > + if (pad) { > + uint32_t cv = data[*len-pad] << 16; > + *(o-1) = '='; > + *(o-2) = '='; > + if (pad == 2) { > + cv |= data[*len-pad+1] << 8; > + *(o-2) = b64encode_tbl[(cv >> 6) & 0x3f]; > + } > + *(o-3) = b64encode_tbl[(cv >> 12) & 0x3f]; > + *(o-4) = b64encode_tbl[(cv >> 18) & 0x3f]; > + } lots of missing spaces here aswell. > + > + out[lenout] = 0; > + *len = lenout; > + return out; > +} > + the base64 code should probably be cleaned up and moved to libubox, same as md5. did not read the rest of the patch as it wont be merged as is. > +static const unsigned char b64decode_tbl[] = { > + 0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36, > + 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, > + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, > + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, > + 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, > + 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, > + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1b, > + 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, > + 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, > + 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33 > +}; > + > +static void > +*b64decode(const char *in, size_t *len) > +{ > + size_t lenout, i; > + > + if (*len == 0) { > + return strdup(""); > + } else if (*len % 4) { > + errno = EINVAL; > + return NULL; > + } > + > + lenout = *len / 4 * 3; > + > + unsigned char *out = calloc(lenout + 1, sizeof(char)); > + if (!out) > + return NULL; > + > + unsigned char *o = out; > + for (i = 0; i < *len; i += 4) { > + uint32_t cv = 0; > + for (int j = 0; j < 4; j++) { > + unsigned char c = in[i + j] - 43; > + if (c > 79 || (c = b64decode_tbl[c]) == 0xff) { > + free(out); > + errno = EINVAL; > + return NULL; > + } > + > +
Re: [OpenWrt-Devel] [PATCH 3/3] [rpcd] file: add support for setting mode when writing files
On 15/03/2015 22:00, Luka Perkov wrote: > Signed-off-by: Luka Perkov > --- > file.c | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/file.c b/file.c > index 54f5d8a..95dd4d4 100644 > --- a/file.c > +++ b/file.c > @@ -92,6 +92,7 @@ static const struct blobmsg_policy > rpc_file_rb_policy[__RPC_F_RB_MAX] = { > enum { > RPC_F_RW_PATH, > RPC_F_RW_DATA, > + RPC_F_RW_MODE, > RPC_F_RW_BASE64, > __RPC_F_RW_MAX, > }; > @@ -99,6 +100,7 @@ enum { > static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { > [RPC_F_RW_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING }, > [RPC_F_RW_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING }, > + [RPC_F_RW_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_INT32 }, > [RPC_F_RW_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL }, > }; > > @@ -372,6 +374,7 @@ rpc_file_write(struct ubus_context *ctx, struct > ubus_object *obj, > { > struct blob_attr *tb[__RPC_F_RW_MAX]; > bool base64 = false; > + mode_t mode = 0644; > int fd, rv = 0; > void *rbuf; > size_t rbuf_len; > @@ -382,12 +385,16 @@ rpc_file_write(struct ubus_context *ctx, struct > ubus_object *obj, > if (!tb[RPC_F_RW_PATH] || !tb[RPC_F_RW_DATA]) > return UBUS_STATUS_INVALID_ARGUMENT; > > - if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | > O_TRUNC)) < 0) > - return rpc_errno_status(); > + if (tb[RPC_F_RW_MODE]) > + mode = blobmsg_get_u32(tb[RPC_F_RW_MODE]); > > if (tb[RPC_F_RW_BASE64]) > base64 = blobmsg_get_bool(tb[RPC_F_RW_BASE64]); > > + umask(0); setting umask to 0 and then not resetting it to the old value afterwards seems wrong. ->> main.c: umask(0077); > + if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | > O_TRUNC, mode)) < 0) > + return rpc_errno_status(); > + > if (base64) { > rbuf_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; > rbuf = b64decode(blobmsg_data(tb[RPC_F_RW_DATA]), &rbuf_len); > ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] TEW-632BRP reboots on latest trunk with ipset enabled
Hi. I've got Trendnet TEW-632BRP running trunk and using ipset to close access to couple of sites. It was working fine but latest trunk makes router restart each 5-10 mins. I've bisected this to commit [44671] (and [44742] that uses it). With these two commits reverted reboots no longer happen. What would be the best way to debug this problem further? Thanks. -- Martynov Nikolay. Email: mar.ko...@gmail.com ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] kernel: Support kernel options required by systemd
(John: This patch takes into account r44765, but moves the FHANDLE config stanza to a more understandable position in the file.) These are all likely to be widely useful in this modern age, but my interest is primarily in systemd support. :-) c.f. http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/systemd/systemd-.ebuild?&view=markup#l118 Adapted from a patch by Adam Porter. Signed-off-by: Jeff Waugh --- config/Config-kernel.in | 34 -- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 34e07bd..ae5b3d5 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -115,6 +115,18 @@ config KERNEL_DIRECT_IO bool "Compile the kernel with direct IO support" default n +config KERNEL_FHANDLE + bool "Compile the kernel with support for fhandle syscalls" + default n + +config KERNEL_FANOTIFY + bool "Compile the kernel with modern file notification support" + default n + +config KERNEL_BLK_DEV_BSG + bool "Compile the kernel with SCSI generic v4 support for any block device" + default n + config KERNEL_MAGIC_SYSRQ bool "Compile the kernel with SysRq support" default y @@ -164,6 +176,22 @@ config USE_SPARSE bool "Enable sparse check during kernel build" default n +config KERNEL_DEVTMPFS + bool "Compile the kernel with device tmpfs enabled" + default n + help + devtmpfs is a simple, kernel-managed /dev filesystem. The kernel creates + devices nodes for all registered devices ti simplify boot, but leaves more + complex tasks to userspace (e.g. udev). + +if KERNEL_DEVTMPFS + + config KERNEL_DEVTMPFS_MOUNT + bool "Automatically mount devtmpfs after root filesystem is mounted" + default n + +endif + # # CGROUP support symbols # @@ -481,9 +509,3 @@ config KERNEL_SECCOMP_FILTER default n help Build kernel with support for seccomp BPF programs. - -config KERNEL_FHANDLE - bool "Enable open by fhandle syscalls" - default n - help - Build kernel with support for open by fhandle syscalls -- 1.9.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] linux: modules: crypto: adds ccm package
This patch adds support crypto-ccm modules support. Signed-off-by: Varka Bhadram --- package/kernel/linux/modules/crypto.mk | 11 +++ 1 file changed, 11 insertions(+) diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk index 4df2d73..ef5f3a9 100644 --- a/package/kernel/linux/modules/crypto.mk +++ b/package/kernel/linux/modules/crypto.mk @@ -314,6 +314,17 @@ endef $(eval $(call KernelPackage,crypto-ctr)) +define KernelPackage/crypto-ccm + TITLE:=Support for Counter with CBC MAC (CCM) + DEPENDS:=+kmod-crypto-ctr +kmod-crypto-aead + KCONFIG:=CONFIG_CRYPTO_CCM + FILES:=$(LINUX_DIR)/crypto/ccm.ko + AUTOLOAD:=$(call AutoLoad,09,ccm) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-ccm)) + define KernelPackage/crypto-pcbc TITLE:=Propagating Cipher Block Chaining CryptoAPI module DEPENDS:=+kmod-crypto-manager -- 1.7.9.5 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] kernel: Support kernel options required by systemd
On 14 March 2015 at 00:35, Jeff Waugh wrote: > (John: This patch takes into account r44765, but moves the FHANDLE config > stanza to a more understandable position in the file.) If you want to put some comments in your patch, place them below the "---". This way they won't be visible after applying patch with "git am". > These are all likely to be widely useful in this modern age, but my interest > is > primarily in systemd support. :-) > > c.f. > http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/systemd/systemd-.ebuild?&view=markup#l118 > > Adapted from a patch by Adam Porter. > > Signed-off-by: Jeff Waugh > --- Right here. -- Rafał ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] kernel: Support kernel options required by systemd
On Mon, Mar 16, 2015 at 4:56 PM, Rafał Miłecki wrote: > If you want to put some comments in your patch, place them below the > "---". This way they won't be visible after applying patch with "git > am". Thanks -- will do. 8) ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel