Merge "[Feature]merge ethernet from gsw" into MR3.0-merge
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0004-connman-add-telephony-plugin.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0004-connman-add-telephony-plugin.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0005-connman-build-plugin-telephon.c.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0005-connman-build-plugin-telephon.c.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0006-connman-disable-cellular-network-from-auto-connect.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0006-connman-disable-cellular-network-from-auto-connect.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0007-connman-set-ccmnix-interface-to-cellular-type.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0007-connman-set-ccmnix-interface-to-cellular-type.patch
old mode 100644
new mode 100755
index d445ed9..8c3e9f6
--- a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0007-connman-set-ccmnix-interface-to-cellular-type.patch
+++ b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0007-connman-set-ccmnix-interface-to-cellular-type.patch
@@ -52,10 +52,11 @@
FILE *f;
name = connman_inet_ifname(interface->index);
-@@ -127,7 +127,12 @@ static void read_uevent(struct interface_data *interface)
+@@ -128,7 +128,12 @@ static void read_uevent(struct interface_data *interface)
if (ether_blacklisted(name)) {
interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
+ goto out;
- } else {
+ }else if (strncmp(name, "ccmni", 5) == 0){
+ interface->service_type = CONNMAN_SERVICE_TYPE_CELLULAR;
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0008-connman-not-set-ip-for-ccmnix-interface.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0008-connman-not-set-ip-for-ccmnix-interface.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0009-connman-enable-log-for-debug.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0009-connman-enable-log-for-debug.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0010-connman-telephony-plugin-rename-telephony-plugin.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0010-connman-telephony-plugin-rename-telephony-plugin.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0011-connman-data-for-sdk-server.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0011-connman-data-for-sdk-server.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0011-connmand-sync-code-fixed-assert-when-get-method-call.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0011-connmand-sync-code-fixed-assert-when-get-method-call.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0012-connman-fix-setup-datacall-deactivate-datacall-issue.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0012-connman-fix-setup-datacall-deactivate-datacall-issue.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0012-connman-set-timeout-to-DBUS_TIMEOUT_INFINITE.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0012-connman-set-timeout-to-DBUS_TIMEOUT_INFINITE.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0013-connman-not-to-save-load-config-information-for-cell.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0013-connman-not-to-save-load-config-information-for-cell.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0014-connman-disable-connman-to-clear-ip-address-when-dis.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0014-connman-disable-connman-to-clear-ip-address-when-dis.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0015-connman-set-ipv6-route-and-dns.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0015-connman-set-ipv6-route-and-dns.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0016-connman-access-null-pointer-for-some-timing.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0016-connman-access-null-pointer-for-some-timing.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0017-connman-can_not_disconnect_after_telephony_reboot.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0017-connman-can_not_disconnect_after_telephony_reboot.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0018-connman-service_start_after_network.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0018-connman-service_start_after_network.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0019-connman-add-ethernet-tethering.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0019-connman-add-ethernet-tethering.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0020-connman-fix-dns-setting.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0020-connman-fix-dns-setting.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0021-connman-fix-ipv6-route.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0021-connman-fix-ipv6-route.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0022-connman-fix-pdn-change.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0022-connman-fix-pdn-change.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0023-connman-ipv6-tethering.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0023-connman-ipv6-tethering.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0024-connman-telephony-pdn-disconnect.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0024-connman-telephony-pdn-disconnect.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0025-connman-fix-null-pointer.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0025-connman-fix-null-pointer.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0026-connman-fix-null-pointer_2.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0026-connman-fix-null-pointer_2.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0027-connman-fix-wispr-SIGSEGV.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0027-connman-fix-wispr-SIGSEGV.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0028-connman-change-tethering-ip.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0028-connman-change-tethering-ip.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0029-connman-fix-ipv6-ping.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0029-connman-fix-ipv6-ping.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0030-connman-fix-crash.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0030-connman-fix-crash.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0031-connman-change-message-type.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0031-connman-change-message-type.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0032-connman-fix-ipv6-tethering.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0032-connman-fix-ipv6-tethering.patch
old mode 100644
new mode 100755
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0033-connman-fix-ipv6-tethering_V2.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0033-connman-fix-ipv6-tethering_V2.patch
old mode 100644
new mode 100755
index f9ac28a..cc20477
--- a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0033-connman-fix-ipv6-tethering_V2.patch
+++ b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0033-connman-fix-ipv6-tethering_V2.patch
@@ -229,1075 +229,3 @@
return TRUE;
}
-diff --git a/src/tethering.c b/src/tethering.c
-index e358729..c3af44d 100644
---- a/src/tethering.c
-+++ b/src/tethering.c
-@@ -48,7 +48,7 @@
-
- #define BRIDGE_NAME "tether"
-
--#define DEFAULT_MTU 1500
-+#define DEFAULT_MTU 1500
-
- static char *private_network_primary_dns = NULL;
- static char *private_network_secondary_dns = NULL;
-@@ -60,38 +60,38 @@ static DBusConnection *connection;
- static GHashTable *pn_hash;
-
- struct connman_private_network {
-- char *owner;
-- char *path;
-- guint watch;
-- DBusMessage *msg;
-- DBusMessage *reply;
-- int fd;
-- char *interface;
-- int index;
-- guint iface_watch;
-- struct connman_ippool *pool;
-- char *primary_dns;
-- char *secondary_dns;
-+ char *owner;
-+ char *path;
-+ guint watch;
-+ DBusMessage *msg;
-+ DBusMessage *reply;
-+ int fd;
-+ char *interface;
-+ int index;
-+ guint iface_watch;
-+ struct connman_ippool *pool;
-+ char *primary_dns;
-+ char *secondary_dns;
- };
-
- static void radvd_onoff(bool onoff)
- {
-- if(onoff){
-- system("radvd -C /var/lib/connman/radvd.conf");
-- }else{
-- system("killall radvd");
-- }
-+ if(onoff){
-+ system("radvd -C /var/lib/connman/radvd.conf");
-+ }else{
-+ system("killall radvd");
-+ }
- }
-
- static int write_radvd_conf(char *prefix, int prefix_len,char *dnsaddr)
- {
-- FILE *fp=NULL;
-- fp=fopen("/var/lib/connman/radvd.conf","w");
-- if(fp==NULL)
-- return -1;
-- /*
-- interface tether
-- {
-+ FILE *fp=NULL;
-+ fp=fopen("/var/lib/connman/radvd.conf","w");
-+ if(fp==NULL)
-+ return -1;
-+ /*
-+ interface tether
-+ {
- AdvSendAdvert on;
- MinRtrAdvInterval 3;
- MaxRtrAdvInterval 5;
-@@ -105,26 +105,26 @@ static int write_radvd_conf(char *prefix, int prefix_len,char *dnsaddr)
- RDNSS 2409:894c:c36:54a3::bb{
- AdvRDNSSLifetime 3600;
- };
-- };
-- */
-- fprintf(fp,"interface %s\n",BRIDGE_NAME);
-- fprintf(fp,"{\n");
-- fprintf(fp," AdvSendAdvert on;\n");
-- fprintf(fp," MinRtrAdvInterval 3;\n");
-- fprintf(fp," MaxRtrAdvInterval 5;\n");
-- fprintf(fp," AdvManagedFlag off;\n");
-- fprintf(fp," AdvOtherConfigFlag off;\n");
-- fprintf(fp," AdvDefaultPreference high;\n");
-- fprintf(fp," prefix %s/%d{\n",prefix,prefix_len);
-- fprintf(fp," AdvValidLifetime 3600;\n");
-- fprintf(fp," AdvPreferredLifetime 3600;\n");
-- fprintf(fp," };\n");
-- fprintf(fp," RDNSS %s{\n",dnsaddr);
-- fprintf(fp," AdvRDNSSLifetime 3600;\n");
-- fprintf(fp," };\n");
-- fprintf(fp,"};\n");
-- fclose(fp);
-- return 0;
-+ };
-+ */
-+ fprintf(fp,"interface %s\n",BRIDGE_NAME);
-+ fprintf(fp,"{\n");
-+ fprintf(fp," AdvSendAdvert on;\n");
-+ fprintf(fp," MinRtrAdvInterval 3;\n");
-+ fprintf(fp," MaxRtrAdvInterval 5;\n");
-+ fprintf(fp," AdvManagedFlag off;\n");
-+ fprintf(fp," AdvOtherConfigFlag off;\n");
-+ fprintf(fp," AdvDefaultPreference high;\n");
-+ fprintf(fp," prefix %s/%d{\n",prefix,prefix_len);
-+ fprintf(fp," AdvValidLifetime 3600;\n");
-+ fprintf(fp," AdvPreferredLifetime 3600;\n");
-+ fprintf(fp," };\n");
-+ fprintf(fp," RDNSS %s{\n",dnsaddr);
-+ fprintf(fp," AdvRDNSSLifetime 3600;\n");
-+ fprintf(fp," };\n");
-+ fprintf(fp,"};\n");
-+ fclose(fp);
-+ return 0;
- }
- bool writeToFile(const char* filename, const char* value) {
- int fd = open(filename, O_WRONLY);
-@@ -143,534 +143,539 @@ bool writeToFile(const char* filename, const char* value) {
-
- int __connman_ipv6_tethering_setup()
- {
-- if(tethering_enabled && get_pdnstatus_is_connected())
-- {
-- radvd_onoff(false);
-- char prefix[INET6_ADDRSTRLEN + 1];
-- int prefix_len=0;
-- int index;
-- struct in6_addr src;
-- char addr_str[INET6_ADDRSTRLEN + 1];
-- index = connman_inet_ifindex(BRIDGE_NAME);
-- int ret = __connman_inet_get_interface_ll_address(index,AF_INET6,&src);
-- if(ret<0){
-- DBG("get interface link local address fail");
-- return -1;
-- }
-- inet_ntop(AF_INET6, &src, addr_str, INET6_ADDRSTRLEN);
-- DBG("ret %d address %s",ret,addr_str);
--
-- ret = get_ipv6_prefix_address(prefix,&prefix_len);
-- DBG("ret %d prefix %s %d",ret,prefix,prefix_len);
-- if(ret<0){
-- DBG("get interface prefix fail");
-- return -1;
-- }
-- //enable forwarding
-- writeToFile("/proc/sys/net/ipv6/conf/all/forwarding","1");
-- //set tether ip address
-- writeToFile("/proc/sys/net/ipv6/conf/tether/accept_ra","0");
-- char buffer[256];
-- sprintf(buffer,"ip -6 addr add %sbb/%d dev tether",prefix,prefix_len);
-- __connman_inet_add_fwmark_rule(1030, AF_INET6, 0);
-- system(buffer);
-- //write radvd conf
-- write_radvd_conf(prefix,prefix_len,addr_str);
-- //enable radvd
-- radvd_onoff(true);
-- }else{
-- radvd_onoff(false);
-- writeToFile("/proc/sys/net/ipv6/conf/all/forwarding","0");
-- __connman_inet_del_fwmark_rule(1030, AF_INET6, 0);
-- }
-+ int index;
-+ index = connman_inet_ifindex(BRIDGE_NAME);
-+ int table_num=1000+index;
-+
-+ if(tethering_enabled && get_pdnstatus_is_connected())
-+ {
-+ radvd_onoff(false);
-+ char prefix[INET6_ADDRSTRLEN + 1];
-+ int prefix_len=0;
-+
-+ struct in6_addr src;
-+ char addr_str[INET6_ADDRSTRLEN + 1];
-+
-+ int ret = __connman_inet_get_interface_ll_address(index,AF_INET6,&src);
-+ if(ret<0){
-+ DBG("get interface link local address fail");
-+ return -1;
-+ }
-+ inet_ntop(AF_INET6, &src, addr_str, INET6_ADDRSTRLEN);
-+ DBG("ret %d address %s",ret,addr_str);
-+
-+ ret = get_ipv6_prefix_address(prefix,&prefix_len);
-+ DBG("ret %d prefix %s %d",ret,prefix,prefix_len);
-+ if(ret<0){
-+ DBG("get interface prefix fail");
-+ return -1;
-+ }
-+ //enable forwarding
-+ writeToFile("/proc/sys/net/ipv6/conf/all/forwarding","1");
-+ //set tether ip address
-+ writeToFile("/proc/sys/net/ipv6/conf/tether/accept_ra","0");
-+ char buffer[256];
-+ sprintf(buffer,"ip -6 addr add %sbb/%d dev tether",prefix,prefix_len);
-+
-+ __connman_inet_add_fwmark_rule(table_num, AF_INET6, 0);
-+ system(buffer);
-+ //write radvd conf
-+ write_radvd_conf(prefix,prefix_len,addr_str);
-+ //enable radvd
-+ radvd_onoff(true);
-+ }else{
-+ radvd_onoff(false);
-+ writeToFile("/proc/sys/net/ipv6/conf/all/forwarding","0");
-+ __connman_inet_del_fwmark_rule(table_num, AF_INET6, 0);
-+ }
- }
-
-
-
- const char *__connman_tethering_get_bridge(void)
- {
-- int sk, err;
-- unsigned long args[3];
--
-- sk = socket(AF_INET, SOCK_STREAM, 0);
-- if (sk < 0)
-- return NULL;
--
-- args[0] = BRCTL_GET_VERSION;
-- args[1] = args[2] = 0;
-- err = ioctl(sk, SIOCGIFBR, &args);
-- close(sk);
-- if (err == -1) {
-- connman_error("Missing support for 802.1d ethernet bridging");
-- return NULL;
-- }
--
-- return BRIDGE_NAME;
-+ int sk, err;
-+ unsigned long args[3];
-+
-+ sk = socket(AF_INET, SOCK_STREAM, 0);
-+ if (sk < 0)
-+ return NULL;
-+
-+ args[0] = BRCTL_GET_VERSION;
-+ args[1] = args[2] = 0;
-+ err = ioctl(sk, SIOCGIFBR, &args);
-+ close(sk);
-+ if (err == -1) {
-+ connman_error("Missing support for 802.1d ethernet bridging");
-+ return NULL;
-+ }
-+
-+ return BRIDGE_NAME;
- }
-
- static void dhcp_server_debug(const char *str, void *data)
- {
-- connman_info("%s: %s\n", (const char *) data, str);
-+ connman_info("%s: %s\n", (const char *) data, str);
- }
-
- static void dhcp_server_error(GDHCPServerError error)
- {
-- switch (error) {
-- case G_DHCP_SERVER_ERROR_NONE:
-- connman_error("OK");
-- break;
-- case G_DHCP_SERVER_ERROR_INTERFACE_UNAVAILABLE:
-- connman_error("Interface unavailable");
-- break;
-- case G_DHCP_SERVER_ERROR_INTERFACE_IN_USE:
-- connman_error("Interface in use");
-- break;
-- case G_DHCP_SERVER_ERROR_INTERFACE_DOWN:
-- connman_error("Interface down");
-- break;
-- case G_DHCP_SERVER_ERROR_NOMEM:
-- connman_error("No memory");
-- break;
-- case G_DHCP_SERVER_ERROR_INVALID_INDEX:
-- connman_error("Invalid index");
-- break;
-- case G_DHCP_SERVER_ERROR_INVALID_OPTION:
-- connman_error("Invalid option");
-- break;
-- case G_DHCP_SERVER_ERROR_IP_ADDRESS_INVALID:
-- connman_error("Invalid address");
-- break;
-- }
-+ switch (error) {
-+ case G_DHCP_SERVER_ERROR_NONE:
-+ connman_error("OK");
-+ break;
-+ case G_DHCP_SERVER_ERROR_INTERFACE_UNAVAILABLE:
-+ connman_error("Interface unavailable");
-+ break;
-+ case G_DHCP_SERVER_ERROR_INTERFACE_IN_USE:
-+ connman_error("Interface in use");
-+ break;
-+ case G_DHCP_SERVER_ERROR_INTERFACE_DOWN:
-+ connman_error("Interface down");
-+ break;
-+ case G_DHCP_SERVER_ERROR_NOMEM:
-+ connman_error("No memory");
-+ break;
-+ case G_DHCP_SERVER_ERROR_INVALID_INDEX:
-+ connman_error("Invalid index");
-+ break;
-+ case G_DHCP_SERVER_ERROR_INVALID_OPTION:
-+ connman_error("Invalid option");
-+ break;
-+ case G_DHCP_SERVER_ERROR_IP_ADDRESS_INVALID:
-+ connman_error("Invalid address");
-+ break;
-+ }
- }
-
- static GDHCPServer *dhcp_server_start(const char *bridge,
-- const char *router, const char *subnet,
-- const char *start_ip, const char *end_ip,
-- unsigned int lease_time, const char *dns)
-+ const char *router, const char *subnet,
-+ const char *start_ip, const char *end_ip,
-+ unsigned int lease_time, const char *dns)
- {
-- GDHCPServerError error;
-- GDHCPServer *dhcp_server;
-- int index;
-+ GDHCPServerError error;
-+ GDHCPServer *dhcp_server;
-+ int index;
-
-- DBG("");
-+ DBG("");
-
-- index = connman_inet_ifindex(bridge);
-- if (index < 0)
-- return NULL;
-+ index = connman_inet_ifindex(bridge);
-+ if (index < 0)
-+ return NULL;
-
-- dhcp_server = g_dhcp_server_new(G_DHCP_IPV4, index, &error);
-- if (!dhcp_server) {
-- dhcp_server_error(error);
-- return NULL;
-- }
-+ dhcp_server = g_dhcp_server_new(G_DHCP_IPV4, index, &error);
-+ if (!dhcp_server) {
-+ dhcp_server_error(error);
-+ return NULL;
-+ }
-
-- g_dhcp_server_set_debug(dhcp_server, dhcp_server_debug, "DHCP server");
-+ g_dhcp_server_set_debug(dhcp_server, dhcp_server_debug, "DHCP server");
-
-- g_dhcp_server_set_lease_time(dhcp_server, lease_time);
-- g_dhcp_server_set_option(dhcp_server, G_DHCP_SUBNET, subnet);
-- g_dhcp_server_set_option(dhcp_server, G_DHCP_ROUTER, router);
-- g_dhcp_server_set_option(dhcp_server, G_DHCP_DNS_SERVER, dns);
-- g_dhcp_server_set_ip_range(dhcp_server, start_ip, end_ip);
-+ g_dhcp_server_set_lease_time(dhcp_server, lease_time);
-+ g_dhcp_server_set_option(dhcp_server, G_DHCP_SUBNET, subnet);
-+ g_dhcp_server_set_option(dhcp_server, G_DHCP_ROUTER, router);
-+ g_dhcp_server_set_option(dhcp_server, G_DHCP_DNS_SERVER, dns);
-+ g_dhcp_server_set_ip_range(dhcp_server, start_ip, end_ip);
-
-- g_dhcp_server_start(dhcp_server);
-+ g_dhcp_server_start(dhcp_server);
-
-- return dhcp_server;
-+ return dhcp_server;
- }
-
- static void dhcp_server_stop(GDHCPServer *server)
- {
-- if (!server)
-- return;
-+ if (!server)
-+ return;
-
-- g_dhcp_server_unref(server);
-+ g_dhcp_server_unref(server);
- }
-
- static void tethering_restart(struct connman_ippool *pool, void *user_data)
- {
-- DBG("pool %p", pool);
-- __connman_tethering_set_disabled();
-- __connman_tethering_set_enabled();
-+ DBG("pool %p", pool);
-+ __connman_tethering_set_disabled();
-+ __connman_tethering_set_enabled();
- }
-
- int __connman_tethering_set_enabled(void)
- {
-- int index;
-- int err;
-- const char *gateway;
-- const char *broadcast;
-- const char *subnet_mask;
-- const char *start_ip;
-- const char *end_ip;
-- const char *dns;
-- unsigned char prefixlen;
-- char **ns;
--
-- DBG("enabled %d", tethering_enabled + 1);
--
-- if (__sync_fetch_and_add(&tethering_enabled, 1) != 0)
-- return 0;
--
-- err = __connman_bridge_create(BRIDGE_NAME);
-- if (err < 0) {
-- __sync_fetch_and_sub(&tethering_enabled, 1);
-- return -EOPNOTSUPP;
-- }
--
-- index = connman_inet_ifindex(BRIDGE_NAME);
-- dhcp_ippool = __connman_ippool_create(index, 2, 252,
-- tethering_restart, NULL);
-- if (!dhcp_ippool) {
-- connman_error("Fail to create IP pool");
-- __connman_bridge_remove(BRIDGE_NAME);
-- __sync_fetch_and_sub(&tethering_enabled, 1);
-- return -EADDRNOTAVAIL;
-- }
--
-- gateway = __connman_ippool_get_gateway(dhcp_ippool);
-- broadcast = __connman_ippool_get_broadcast(dhcp_ippool);
-- subnet_mask = __connman_ippool_get_subnet_mask(dhcp_ippool);
-- start_ip = __connman_ippool_get_start_ip(dhcp_ippool);
-- end_ip = __connman_ippool_get_end_ip(dhcp_ippool);
--
-- err = __connman_bridge_enable(BRIDGE_NAME, gateway,
-- connman_ipaddress_calc_netmask_len(subnet_mask),
-- broadcast);
-- if (err < 0 && err != -EALREADY) {
-- __connman_ippool_unref(dhcp_ippool);
-- __connman_bridge_remove(BRIDGE_NAME);
-- __sync_fetch_and_sub(&tethering_enabled, 1);
-- return -EADDRNOTAVAIL;
-- }
--
-- ns = connman_setting_get_string_list("FallbackNameservers");
-- if (ns) {
-- if (ns[0]) {
-- g_free(private_network_primary_dns);
-- private_network_primary_dns = g_strdup(ns[0]);
-- }
-- if (ns[1]) {
-- g_free(private_network_secondary_dns);
-- private_network_secondary_dns = g_strdup(ns[1]);
-- }
--
-- DBG("Fallback ns primary %s secondary %s",
-- private_network_primary_dns,
-- private_network_secondary_dns);
-- }
--
-- dns = gateway;
-- if (__connman_dnsproxy_add_listener(index) < 0) {
-- connman_error("Can't add listener %s to DNS proxy",
-- BRIDGE_NAME);
-- dns = private_network_primary_dns;
-- DBG("Serving %s nameserver to clients", dns);
-- }
--
-- tethering_dhcp_server = dhcp_server_start(BRIDGE_NAME,
-- gateway, subnet_mask,
-- start_ip, end_ip,
-- 24 * 3600, dns);
-- if (!tethering_dhcp_server) {
-- __connman_bridge_disable(BRIDGE_NAME);
-- __connman_ippool_unref(dhcp_ippool);
-- __connman_bridge_remove(BRIDGE_NAME);
-- __sync_fetch_and_sub(&tethering_enabled, 1);
-- return -EOPNOTSUPP;
-- }
--
-- prefixlen = connman_ipaddress_calc_netmask_len(subnet_mask);
-- err = __connman_nat_enable(BRIDGE_NAME, start_ip, prefixlen);
-- if (err < 0) {
-- connman_error("Cannot enable NAT %d/%s", err, strerror(-err));
-- dhcp_server_stop(tethering_dhcp_server);
-- __connman_bridge_disable(BRIDGE_NAME);
-- __connman_ippool_unref(dhcp_ippool);
-- __connman_bridge_remove(BRIDGE_NAME);
-- __sync_fetch_and_sub(&tethering_enabled, 1);
-- return -EOPNOTSUPP;
-- }
-+ int index;
-+ int err;
-+ const char *gateway;
-+ const char *broadcast;
-+ const char *subnet_mask;
-+ const char *start_ip;
-+ const char *end_ip;
-+ const char *dns;
-+ unsigned char prefixlen;
-+ char **ns;
-+
-+ DBG("enabled %d", tethering_enabled + 1);
-+
-+ if (__sync_fetch_and_add(&tethering_enabled, 1) != 0)
-+ return 0;
-+
-+ err = __connman_bridge_create(BRIDGE_NAME);
-+ if (err < 0) {
-+ __sync_fetch_and_sub(&tethering_enabled, 1);
-+ return -EOPNOTSUPP;
-+ }
-+
-+ index = connman_inet_ifindex(BRIDGE_NAME);
-+ dhcp_ippool = __connman_ippool_create(index, 2, 252,
-+ tethering_restart, NULL);
-+ if (!dhcp_ippool) {
-+ connman_error("Fail to create IP pool");
-+ __connman_bridge_remove(BRIDGE_NAME);
-+ __sync_fetch_and_sub(&tethering_enabled, 1);
-+ return -EADDRNOTAVAIL;
-+ }
-+
-+ gateway = __connman_ippool_get_gateway(dhcp_ippool);
-+ broadcast = __connman_ippool_get_broadcast(dhcp_ippool);
-+ subnet_mask = __connman_ippool_get_subnet_mask(dhcp_ippool);
-+ start_ip = __connman_ippool_get_start_ip(dhcp_ippool);
-+ end_ip = __connman_ippool_get_end_ip(dhcp_ippool);
-+
-+ err = __connman_bridge_enable(BRIDGE_NAME, gateway,
-+ connman_ipaddress_calc_netmask_len(subnet_mask),
-+ broadcast);
-+ if (err < 0 && err != -EALREADY) {
-+ __connman_ippool_unref(dhcp_ippool);
-+ __connman_bridge_remove(BRIDGE_NAME);
-+ __sync_fetch_and_sub(&tethering_enabled, 1);
-+ return -EADDRNOTAVAIL;
-+ }
-+
-+ ns = connman_setting_get_string_list("FallbackNameservers");
-+ if (ns) {
-+ if (ns[0]) {
-+ g_free(private_network_primary_dns);
-+ private_network_primary_dns = g_strdup(ns[0]);
-+ }
-+ if (ns[1]) {
-+ g_free(private_network_secondary_dns);
-+ private_network_secondary_dns = g_strdup(ns[1]);
-+ }
-+
-+ DBG("Fallback ns primary %s secondary %s",
-+ private_network_primary_dns,
-+ private_network_secondary_dns);
-+ }
-+
-+ dns = gateway;
-+ if (__connman_dnsproxy_add_listener(index) < 0) {
-+ connman_error("Can't add listener %s to DNS proxy",
-+ BRIDGE_NAME);
-+ dns = private_network_primary_dns;
-+ DBG("Serving %s nameserver to clients", dns);
-+ }
-+
-+ tethering_dhcp_server = dhcp_server_start(BRIDGE_NAME,
-+ gateway, subnet_mask,
-+ start_ip, end_ip,
-+ 24 * 3600, dns);
-+ if (!tethering_dhcp_server) {
-+ __connman_bridge_disable(BRIDGE_NAME);
-+ __connman_ippool_unref(dhcp_ippool);
-+ __connman_bridge_remove(BRIDGE_NAME);
-+ __sync_fetch_and_sub(&tethering_enabled, 1);
-+ return -EOPNOTSUPP;
-+ }
-+
-+ prefixlen = connman_ipaddress_calc_netmask_len(subnet_mask);
-+ err = __connman_nat_enable(BRIDGE_NAME, start_ip, prefixlen);
-+ if (err < 0) {
-+ connman_error("Cannot enable NAT %d/%s", err, strerror(-err));
-+ dhcp_server_stop(tethering_dhcp_server);
-+ __connman_bridge_disable(BRIDGE_NAME);
-+ __connman_ippool_unref(dhcp_ippool);
-+ __connman_bridge_remove(BRIDGE_NAME);
-+ __sync_fetch_and_sub(&tethering_enabled, 1);
-+ return -EOPNOTSUPP;
-+ }
- #if 0
-- err = __connman_ipv6pd_setup(BRIDGE_NAME);
-- if (err < 0 && err != -EINPROGRESS)
-- DBG("Cannot setup IPv6 prefix delegation %d/%s", err,
-- strerror(-err));
-+ err = __connman_ipv6pd_setup(BRIDGE_NAME);
-+ if (err < 0 && err != -EINPROGRESS)
-+ DBG("Cannot setup IPv6 prefix delegation %d/%s", err,
-+ strerror(-err));
- #endif
-- __connman_ipv6_tethering_setup();
-+ __connman_ipv6_tethering_setup();
-
-- DBG("tethering started");
-+ DBG("tethering started");
-
-- return 0;
-+ return 0;
- }
-
- void __connman_tethering_set_disabled(void)
- {
-- int index;
-+ int index;
-
-- DBG("enabled %d", tethering_enabled - 1);
-+ DBG("enabled %d", tethering_enabled - 1);
-
-- if (__sync_fetch_and_sub(&tethering_enabled, 1) != 1)
-- return;
-+ if (__sync_fetch_and_sub(&tethering_enabled, 1) != 1)
-+ return;
-
-- __connman_ipv6pd_cleanup();
-+ __connman_ipv6pd_cleanup();
-
-- index = connman_inet_ifindex(BRIDGE_NAME);
-- __connman_dnsproxy_remove_listener(index);
-+ index = connman_inet_ifindex(BRIDGE_NAME);
-+ __connman_dnsproxy_remove_listener(index);
-
-- __connman_nat_disable(BRIDGE_NAME);
-+ __connman_nat_disable(BRIDGE_NAME);
-
-- dhcp_server_stop(tethering_dhcp_server);
-+ dhcp_server_stop(tethering_dhcp_server);
-
-- tethering_dhcp_server = NULL;
-+ tethering_dhcp_server = NULL;
-
-- __connman_bridge_disable(BRIDGE_NAME);
-+ __connman_bridge_disable(BRIDGE_NAME);
-
-- __connman_ippool_unref(dhcp_ippool);
-+ __connman_ippool_unref(dhcp_ippool);
-
-- __connman_bridge_remove(BRIDGE_NAME);
-+ __connman_bridge_remove(BRIDGE_NAME);
-
-- g_free(private_network_primary_dns);
-- private_network_primary_dns = NULL;
-- g_free(private_network_secondary_dns);
-- private_network_secondary_dns = NULL;
-- __connman_ipv6_tethering_setup();
-+ g_free(private_network_primary_dns);
-+ private_network_primary_dns = NULL;
-+ g_free(private_network_secondary_dns);
-+ private_network_secondary_dns = NULL;
-+ __connman_ipv6_tethering_setup();
-
-- DBG("tethering stopped");
-+ DBG("tethering stopped");
- }
-
- static void setup_tun_interface(unsigned int flags, unsigned change,
-- void *data)
-+ void *data)
- {
-- struct connman_private_network *pn = data;
-- unsigned char prefixlen;
-- DBusMessageIter array, dict;
-- const char *server_ip;
-- const char *peer_ip;
-- const char *subnet_mask;
-- int err;
--
-- DBG("index %d flags %d change %d", pn->index, flags, change);
--
-- if (flags & IFF_UP)
-- return;
--
-- subnet_mask = __connman_ippool_get_subnet_mask(pn->pool);
-- server_ip = __connman_ippool_get_start_ip(pn->pool);
-- peer_ip = __connman_ippool_get_end_ip(pn->pool);
-- prefixlen = connman_ipaddress_calc_netmask_len(subnet_mask);
--
-- if ((__connman_inet_modify_address(RTM_NEWADDR,
-- NLM_F_REPLACE | NLM_F_ACK, pn->index, AF_INET,
-- server_ip, peer_ip, prefixlen, NULL)) < 0) {
-- DBG("address setting failed");
-- return;
-- }
-+ struct connman_private_network *pn = data;
-+ unsigned char prefixlen;
-+ DBusMessageIter array, dict;
-+ const char *server_ip;
-+ const char *peer_ip;
-+ const char *subnet_mask;
-+ int err;
-+
-+ DBG("index %d flags %d change %d", pn->index, flags, change);
-+
-+ if (flags & IFF_UP)
-+ return;
-+
-+ subnet_mask = __connman_ippool_get_subnet_mask(pn->pool);
-+ server_ip = __connman_ippool_get_start_ip(pn->pool);
-+ peer_ip = __connman_ippool_get_end_ip(pn->pool);
-+ prefixlen = connman_ipaddress_calc_netmask_len(subnet_mask);
-+
-+ if ((__connman_inet_modify_address(RTM_NEWADDR,
-+ NLM_F_REPLACE | NLM_F_ACK, pn->index, AF_INET,
-+ server_ip, peer_ip, prefixlen, NULL)) < 0) {
-+ DBG("address setting failed");
-+ return;
-+ }
-
-- connman_inet_ifup(pn->index);
-+ connman_inet_ifup(pn->index);
-
-- err = __connman_nat_enable(BRIDGE_NAME, server_ip, prefixlen);
-- if (err < 0) {
-- connman_error("failed to enable NAT");
-- goto error;
-- }
-+ err = __connman_nat_enable(BRIDGE_NAME, server_ip, prefixlen);
-+ if (err < 0) {
-+ connman_error("failed to enable NAT");
-+ goto error;
-+ }
-
-- dbus_message_iter_init_append(pn->reply, &array);
-+ dbus_message_iter_init_append(pn->reply, &array);
-
-- dbus_message_iter_append_basic(&array, DBUS_TYPE_OBJECT_PATH,
-- &pn->path);
-+ dbus_message_iter_append_basic(&array, DBUS_TYPE_OBJECT_PATH,
-+ &pn->path);
-
-- connman_dbus_dict_open(&array, &dict);
-+ connman_dbus_dict_open(&array, &dict);
-
-- connman_dbus_dict_append_basic(&dict, "ServerIPv4",
-- DBUS_TYPE_STRING, &server_ip);
-- connman_dbus_dict_append_basic(&dict, "PeerIPv4",
-- DBUS_TYPE_STRING, &peer_ip);
-- if (pn->primary_dns)
-- connman_dbus_dict_append_basic(&dict, "PrimaryDNS",
-- DBUS_TYPE_STRING, &pn->primary_dns);
-+ connman_dbus_dict_append_basic(&dict, "ServerIPv4",
-+ DBUS_TYPE_STRING, &server_ip);
-+ connman_dbus_dict_append_basic(&dict, "PeerIPv4",
-+ DBUS_TYPE_STRING, &peer_ip);
-+ if (pn->primary_dns)
-+ connman_dbus_dict_append_basic(&dict, "PrimaryDNS",
-+ DBUS_TYPE_STRING, &pn->primary_dns);
-
-- if (pn->secondary_dns)
-- connman_dbus_dict_append_basic(&dict, "SecondaryDNS",
-- DBUS_TYPE_STRING, &pn->secondary_dns);
-+ if (pn->secondary_dns)
-+ connman_dbus_dict_append_basic(&dict, "SecondaryDNS",
-+ DBUS_TYPE_STRING, &pn->secondary_dns);
-
-- connman_dbus_dict_close(&array, &dict);
-+ connman_dbus_dict_close(&array, &dict);
-
-- dbus_message_iter_append_basic(&array, DBUS_TYPE_UNIX_FD, &pn->fd);
-+ dbus_message_iter_append_basic(&array, DBUS_TYPE_UNIX_FD, &pn->fd);
-
-- g_dbus_send_message(connection, pn->reply);
-+ g_dbus_send_message(connection, pn->reply);
-
-- return;
-+ return;
-
- error:
-- pn->reply = __connman_error_failed(pn->msg, -err);
-- g_dbus_send_message(connection, pn->reply);
-+ pn->reply = __connman_error_failed(pn->msg, -err);
-+ g_dbus_send_message(connection, pn->reply);
-
-- g_hash_table_remove(pn_hash, pn->path);
-+ g_hash_table_remove(pn_hash, pn->path);
- }
-
- static void remove_private_network(gpointer user_data)
- {
-- struct connman_private_network *pn = user_data;
-+ struct connman_private_network *pn = user_data;
-
-- __connman_nat_disable(BRIDGE_NAME);
-- connman_rtnl_remove_watch(pn->iface_watch);
-- __connman_ippool_unref(pn->pool);
-+ __connman_nat_disable(BRIDGE_NAME);
-+ connman_rtnl_remove_watch(pn->iface_watch);
-+ __connman_ippool_unref(pn->pool);
-
-- if (pn->watch > 0) {
-- g_dbus_remove_watch(connection, pn->watch);
-- pn->watch = 0;
-- }
-+ if (pn->watch > 0) {
-+ g_dbus_remove_watch(connection, pn->watch);
-+ pn->watch = 0;
-+ }
-
-- close(pn->fd);
-+ close(pn->fd);
-
-- g_free(pn->interface);
-- g_free(pn->owner);
-- g_free(pn->path);
-- g_free(pn->primary_dns);
-- g_free(pn->secondary_dns);
-- g_free(pn);
-+ g_free(pn->interface);
-+ g_free(pn->owner);
-+ g_free(pn->path);
-+ g_free(pn->primary_dns);
-+ g_free(pn->secondary_dns);
-+ g_free(pn);
- }
-
- static void owner_disconnect(DBusConnection *conn, void *user_data)
- {
-- struct connman_private_network *pn = user_data;
-+ struct connman_private_network *pn = user_data;
-
-- DBG("%s died", pn->owner);
-+ DBG("%s died", pn->owner);
-
-- pn->watch = 0;
-+ pn->watch = 0;
-
-- g_hash_table_remove(pn_hash, pn->path);
-+ g_hash_table_remove(pn_hash, pn->path);
- }
-
- static void ippool_disconnect(struct connman_ippool *pool, void *user_data)
- {
-- struct connman_private_network *pn = user_data;
-+ struct connman_private_network *pn = user_data;
-
-- DBG("block used externally");
-+ DBG("block used externally");
-
-- g_hash_table_remove(pn_hash, pn->path);
-+ g_hash_table_remove(pn_hash, pn->path);
- }
-
- int __connman_private_network_request(DBusMessage *msg, const char *owner)
- {
-- struct connman_private_network *pn;
-- char *iface = NULL;
-- char *path = NULL;
-- int index, fd, err;
--
-- if (DBUS_TYPE_UNIX_FD < 0)
-- return -EINVAL;
--
-- fd = connman_inet_create_tunnel(&iface);
-- if (fd < 0)
-- return fd;
--
-- path = g_strdup_printf("/tethering/%s", iface);
--
-- pn = g_hash_table_lookup(pn_hash, path);
-- if (pn) {
-- g_free(path);
-- g_free(iface);
-- close(fd);
-- return -EEXIST;
-- }
--
-- index = connman_inet_ifindex(iface);
-- if (index < 0) {
-- err = -ENODEV;
-- goto error;
-- }
-- DBG("interface %s", iface);
--
-- err = connman_inet_set_mtu(index, DEFAULT_MTU);
--
-- pn = g_try_new0(struct connman_private_network, 1);
-- if (!pn) {
-- err = -ENOMEM;
-- goto error;
-- }
--
-- pn->owner = g_strdup(owner);
-- pn->path = path;
-- pn->watch = g_dbus_add_disconnect_watch(connection, pn->owner,
-- owner_disconnect, pn, NULL);
-- pn->msg = msg;
-- pn->reply = dbus_message_new_method_return(pn->msg);
-- if (!pn->reply)
-- goto error;
--
-- pn->fd = fd;
-- pn->interface = iface;
-- pn->index = index;
-- pn->pool = __connman_ippool_create(pn->index, 1, 1, ippool_disconnect, pn);
-- if (!pn->pool) {
-- errno = -ENOMEM;
-- goto error;
-- }
--
-- pn->primary_dns = g_strdup(private_network_primary_dns);
-- pn->secondary_dns = g_strdup(private_network_secondary_dns);
--
-- pn->iface_watch = connman_rtnl_add_newlink_watch(index,
-- setup_tun_interface, pn);
--
-- g_hash_table_insert(pn_hash, pn->path, pn);
--
-- return 0;
-+ struct connman_private_network *pn;
-+ char *iface = NULL;
-+ char *path = NULL;
-+ int index, fd, err;
-+
-+ if (DBUS_TYPE_UNIX_FD < 0)
-+ return -EINVAL;
-+
-+ fd = connman_inet_create_tunnel(&iface);
-+ if (fd < 0)
-+ return fd;
-+
-+ path = g_strdup_printf("/tethering/%s", iface);
-+
-+ pn = g_hash_table_lookup(pn_hash, path);
-+ if (pn) {
-+ g_free(path);
-+ g_free(iface);
-+ close(fd);
-+ return -EEXIST;
-+ }
-+
-+ index = connman_inet_ifindex(iface);
-+ if (index < 0) {
-+ err = -ENODEV;
-+ goto error;
-+ }
-+ DBG("interface %s", iface);
-+
-+ err = connman_inet_set_mtu(index, DEFAULT_MTU);
-+
-+ pn = g_try_new0(struct connman_private_network, 1);
-+ if (!pn) {
-+ err = -ENOMEM;
-+ goto error;
-+ }
-+
-+ pn->owner = g_strdup(owner);
-+ pn->path = path;
-+ pn->watch = g_dbus_add_disconnect_watch(connection, pn->owner,
-+ owner_disconnect, pn, NULL);
-+ pn->msg = msg;
-+ pn->reply = dbus_message_new_method_return(pn->msg);
-+ if (!pn->reply)
-+ goto error;
-+
-+ pn->fd = fd;
-+ pn->interface = iface;
-+ pn->index = index;
-+ pn->pool = __connman_ippool_create(pn->index, 1, 1, ippool_disconnect, pn);
-+ if (!pn->pool) {
-+ errno = -ENOMEM;
-+ goto error;
-+ }
-+
-+ pn->primary_dns = g_strdup(private_network_primary_dns);
-+ pn->secondary_dns = g_strdup(private_network_secondary_dns);
-+
-+ pn->iface_watch = connman_rtnl_add_newlink_watch(index,
-+ setup_tun_interface, pn);
-+
-+ g_hash_table_insert(pn_hash, pn->path, pn);
-+
-+ return 0;
-
- error:
-- close(fd);
-- g_free(iface);
-- g_free(path);
-- if (pn)
-- g_free(pn->owner);
-- g_free(pn);
-- return err;
-+ close(fd);
-+ g_free(iface);
-+ g_free(path);
-+ if (pn)
-+ g_free(pn->owner);
-+ g_free(pn);
-+ return err;
- }
-
- int __connman_private_network_release(const char *path)
- {
-- struct connman_private_network *pn;
-+ struct connman_private_network *pn;
-
-- pn = g_hash_table_lookup(pn_hash, path);
-- if (!pn)
-- return -EACCES;
-+ pn = g_hash_table_lookup(pn_hash, path);
-+ if (!pn)
-+ return -EACCES;
-
-- g_hash_table_remove(pn_hash, path);
-- return 0;
-+ g_hash_table_remove(pn_hash, path);
-+ return 0;
- }
-
- int __connman_tethering_init(void)
- {
-- DBG("");
-+ DBG("");
-
-- tethering_enabled = 0;
-+ tethering_enabled = 0;
-
-- connection = connman_dbus_get_connection();
-- if (!connection)
-- return -EFAULT;
-+ connection = connman_dbus_get_connection();
-+ if (!connection)
-+ return -EFAULT;
-
-- pn_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
-- NULL, remove_private_network);
-+ pn_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
-+ NULL, remove_private_network);
-
-- return 0;
-+ return 0;
- }
-
- void __connman_tethering_cleanup(void)
- {
-- DBG("enabled %d", tethering_enabled);
--
-- __sync_synchronize();
-- if (tethering_enabled > 0) {
-- if (tethering_dhcp_server)
-- dhcp_server_stop(tethering_dhcp_server);
-- __connman_bridge_disable(BRIDGE_NAME);
-- __connman_bridge_remove(BRIDGE_NAME);
-- __connman_nat_disable(BRIDGE_NAME);
-- }
--
-- if (!connection)
-- return;
--
-- g_hash_table_destroy(pn_hash);
-- dbus_connection_unref(connection);
-+ DBG("enabled %d", tethering_enabled);
-+
-+ __sync_synchronize();
-+ if (tethering_enabled > 0) {
-+ if (tethering_dhcp_server)
-+ dhcp_server_stop(tethering_dhcp_server);
-+ __connman_bridge_disable(BRIDGE_NAME);
-+ __connman_bridge_remove(BRIDGE_NAME);
-+ __connman_nat_disable(BRIDGE_NAME);
-+ }
-+
-+ if (!connection)
-+ return;
-+
-+ g_hash_table_destroy(pn_hash);
-+ dbus_connection_unref(connection);
- }
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0034-connman-change-default-rule.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0034-connman-change-default-rule.patch
index d08b4cc..f3257b7 100755
--- a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0034-connman-change-default-rule.patch
+++ b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/0034-connman-change-default-rule.patch
@@ -2,7 +2,7 @@
index 8a743af..30bd1c1 100644
--- a/src/service.c
+++ b/src/service.c
-@@ -1476,12 +1476,28 @@ static void reset_stats(struct connman_service *service)
+@@ -1476,12 +1476,30 @@ static void reset_stats(struct connman_service *service)
struct connman_service *__connman_service_get_default(void)
{
struct connman_service *service;
@@ -15,7 +15,9 @@
service = service_list->data;
-+ ccmni_ptr = service_list;
++ if (is_connected(service->state))
++ return service;
++ ccmni_ptr = service_list;
+
+ while(ccmni_ptr != NULL)
+ {
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/apmode.patch b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/apmode.patch
deleted file mode 100644
index 27510f1..0000000
--- a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman/apmode.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/plugins/wifi.c b/plugins/wifi.c
-index 09869ad..84ce176 100644
---- a/plugins/wifi.c
-+++ b/plugins/wifi.c
-@@ -735,7 +735,7 @@ static void wifi_newlink(unsigned flags, unsigned change, void *user_data)
- DBG("interface down");
- }
-
-- if ((wifi->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) {
-+ if (((wifi->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP))||(wifi->index==connman_inet_ifindex("ap0"))) {
- if (flags & IFF_LOWER_UP) {
- DBG("carrier on");
-
diff --git a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman_%.bbappend b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman_%.bbappend
old mode 100644
new mode 100755
index 61c5b78..37f4891
--- a/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman_%.bbappend
+++ b/meta/meta-mediatek-ivt/recipes-connectivity/connman/connman_%.bbappend
@@ -1,7 +1,6 @@
FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
SRC_URI += "\
- file://apmode.patch \
file://0004-connman-add-telephony-plugin.patch \
file://0005-connman-build-plugin-telephon.c.patch \
file://0006-connman-disable-cellular-network-from-auto-connect.patch \
diff --git a/meta/meta-mediatek-ivt/recipes-core/busybox/busybox/busyboxmakefile.patch b/meta/meta-mediatek-ivt/recipes-core/busybox/busybox/busyboxmakefile.patch
new file mode 100755
index 0000000..b795cbd
--- /dev/null
+++ b/meta/meta-mediatek-ivt/recipes-core/busybox/busybox/busyboxmakefile.patch
@@ -0,0 +1,10 @@
+--- busybox-1.29.3/Makefile 2018-09-10 02:56:44.000000000 +0800
++++ busybox-1.29.3/Makefilenew 2022-09-29 10:53:50.416226016 +0800
+@@ -493,6 +493,7 @@
+ util-linux/ \
+ util-linux/volume_id/ \
+
++libs-y += -ldl
+ endif # KBUILD_EXTMOD
+
+ ifeq ($(dot-config),1)
diff --git a/meta/meta-mediatek-ivt/recipes-core/busybox/busybox/ring_buf_GSW.patch b/meta/meta-mediatek-ivt/recipes-core/busybox/busybox/ring_buf_GSW.patch
new file mode 100755
index 0000000..43e9fc9
--- /dev/null
+++ b/meta/meta-mediatek-ivt/recipes-core/busybox/busybox/ring_buf_GSW.patch
@@ -0,0 +1,63 @@
+--- busybox-1.29.3/sysklogd/syslogd.c 2018-07-02 19:23:06.000000000 +0800
++++ busybox-1.29.3/sysklogd/syslogdnew.c 2022-09-29 13:47:26.318538618 +0800
+@@ -165,6 +165,8 @@
+
+ #include <sys/un.h>
+ #include <sys/uio.h>
++#include <dlfcn.h>
++
+
+ #if ENABLE_FEATURE_REMOTE_LOG
+ #include <netinet/in.h>
+@@ -176,6 +178,9 @@
+ #include <sys/shm.h>
+ #endif
+
++#define ENABLE_FEATURE_SYSLOGD_CFG 1
++#define ENABLE_FEATURE_ROTATE_LOGFILE 1
++int (*lynq_get_value)(char *file, char *section, char *key, char *tmp);
+
+ #define DEBUG 0
+
+@@ -1102,6 +1107,13 @@
+ {
+ int opts;
+ char OPTION_DECL;
++
++ void *handle_uci;
++ static char get_propty_log_data[64] = {0};
++ int lynq_syslog_filesize = 100*1024*1024;
++ int lynq_syslog_rotate = 10;
++ const char *lynq_libpath_uci = "/lib64/liblynq-uci.so";
++
+ #if ENABLE_FEATURE_REMOTE_LOG
+ llist_t *remoteAddrList = NULL;
+ #endif
+@@ -1157,6 +1169,27 @@
+ //umask(0); - why??
+ write_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
+
++ handle_uci = dlopen(lynq_libpath_uci,RTLD_NOW);
++ lynq_get_value = (int (*)(void))dlsym(handle_uci,"lynq_get_value");
++ if(NULL != lynq_get_value)
++ {
++ memset(get_propty_log_data,0,64);
++ if(0 == lynq_get_value("lynq_uci","lynq_log","syslog_flie_size",get_propty_log_data))
++ {
++ lynq_syslog_filesize = atoi(get_propty_log_data);
++ printf("lynq_syslog_filesize:%d\n",lynq_syslog_filesize);
++ }
++ memset(get_propty_log_data,0,64);
++ if(0 == lynq_get_value("lynq_uci","lynq_log","syslog_flie_rotate",get_propty_log_data))
++ {
++ lynq_syslog_rotate = atoi(get_propty_log_data);
++ printf("lynq_syslog_rotate:%d\n",lynq_syslog_rotate);
++ }
++ }
++
++ G.logFileSize = lynq_syslog_filesize;
++ G.logFileRotate = lynq_syslog_rotate;
++
+ do_syslogd();
+ /* return EXIT_SUCCESS; */
+ }
diff --git a/meta/meta-mediatek-ivt/recipes-core/busybox/busybox_%.bbappend b/meta/meta-mediatek-ivt/recipes-core/busybox/busybox_%.bbappend
index bfa00c9..b95acb6 100755
--- a/meta/meta-mediatek-ivt/recipes-core/busybox/busybox_%.bbappend
+++ b/meta/meta-mediatek-ivt/recipes-core/busybox/busybox_%.bbappend
@@ -11,13 +11,26 @@
file://busybox-syslog.service.in \
file://busybox-klogd.service.in \
file://tcpdump-start \
- file://ring_buf.patch \
file://busybox_syslog_high_precision_timestamp.patch \
file://coredump.service.in \
file://coredump-start \
file://coredump-handler.sh \
file://0001-Revert-remove-systemd-support.patch \
"
+
+SRC_URI_append += "\
+ ${@bb.utils.contains('MOBILETEK_BUSYBOX_CFG', 'GSW', 'file://busyboxmakefile.patch', '', d)} \
+"
+
+SRC_URI_append += "\
+ ${@bb.utils.contains('MOBILETEK_BUSYBOX_CFG', 'PLATFORM', 'file://ring_buf.patch', '', d)} \
+"
+
+SRC_URI_append += "\
+ ${@bb.utils.contains('MOBILETEK_BUSYBOX_CFG', 'GSW', 'file://ring_buf_GSW.patch', '', d)} \
+"
+
+
inherit systemd
SYSTEMD_SERVICE_${PN}-syslog_append = "${@bb.utils.contains('BUILD_LOAD_TYPE', 'user', ' coredump.service', ' coredump.service', d)}"
diff --git a/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-base.conf b/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-base.conf
index 64304bf..030d0f5 100755
--- a/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-base.conf
+++ b/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-base.conf
@@ -147,7 +147,7 @@
SCATTER_PROJECT = "auto2735-ivt-mcp_nand"
# Modem
-MODEM_PROJECT = "MT2735_V02.MP1_MR3_NLWG_T2_20220924"
+MODEM_PROJECT = "MT2735_V02.MP1_MR3_NLWG_T19_20221118"
MODEM_INT = "${TOPDIR}/../prebuilt/modem/mt2735_internal"
MODEM_CUSTOM = "${TOPDIR}/../prebuilt/modem/mt2735"
MODEM_INT_EXIST = "${@ os.path.exists('${MODEM_INT}')}"
diff --git a/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-main.conf b/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-main.conf
index 310e1d7..e0eda4f 100755
--- a/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-main.conf
+++ b/meta/meta-mediatek-mt2735/conf/machine/auto2735evb-ivt-main.conf
@@ -62,3 +62,17 @@
#EMMC_CFG value:"PLATFORM","GSW"
MOBILETEK_EMMC_CFG = "PLATFORM"
+#WIFIKERNELCODE_CFG value:"PLATFORM","GSW"
+MOBILETEK_WIFIKERNELCODE_CFG = "PLATFORM"
+
+#SYSTEMD_CFG value:"PLATFORM","GSW"
+MOBILETEK_SYSTEMD_CFG = "PLATFORM"
+
+#GSTREAMER_CFG value:"PLATFORM","GSW"
+MOBILETEK_GSTREAMER_CFG = "PLATFORM"
+
+#BUSYBOX_CFG value:"PLATFORM","GSW"
+MOBILETEK_BUSYBOX_CFG = "PLATFORM"
+
+#OPENSSH_CFG value:"PLATFORM","GSW"
+MOBILETEK_OPENSSH_CFG = "PLATFORM"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_ap_cache_hostname.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_ap_cache_hostname.patch
new file mode 100755
index 0000000..8cd4ca2
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_ap_cache_hostname.patch
@@ -0,0 +1,249 @@
+--- connman-1.41/src/dnsproxy.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/src/dnsproxy_new.c 2022-08-27 15:39:40.864223400 +0800
+@@ -41,6 +41,7 @@
+
+ #include "connman.h"
+
++#include <gdhcp/gdhcp.h>
+ #define debug(fmt...) do { } while (0)
+
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+@@ -514,6 +515,47 @@
+ }
+ }
+
++static void send_ok_response(int sk, unsigned char *buf, size_t len,
++ const struct sockaddr *to, socklen_t tolen,
++ const char *hostname)
++{
++ struct domain_hdr *hdr;
++ int err,hostname_len;
++
++ debug("sk %d", sk);
++ hdr = (void *) (buf);
++
++ debug("cy----id 0x%04x qr %d opcode %d", hdr->id, hdr->qr, hdr->opcode);
++
++ hdr->qr = 1;
++ hdr->aa = 1;
++ hdr->rcode = ns_r_noerror;
++
++// hdr->qdcount = 1;
++// hdr->ancount = 1;
++ buf[5] = 1;
++ buf[7] = 1;
++ hdr->nscount = 0;
++ hdr->arcount = 0;
++
++ hdr->ra = 1;
++ hdr->aa = 1;
++ memcpy(buf + len, "\xc0\x0c\x00\x0c\x00\x01\x00\x00\x00\x00\x00", 11);
++ len += 11;
++ hostname_len = strlen(hostname);
++ buf[len++] = hostname_len+ 1;
++ buf[len++] = hostname_len;
++ memcpy(buf + len, hostname, hostname_len);
++ len += hostname_len;
++ buf[len++] = 0;
++ err = sendto(sk, buf, len, MSG_NOSIGNAL, to, tolen);
++ if (err < 0) {
++ connman_error("Failed to send DNS response to %d: %s",
++ sk, strerror(errno));
++ return;
++ }
++}
++
+ static int get_req_udp_socket(struct request_data *req)
+ {
+ GIOChannel *channel;
+@@ -3560,6 +3602,41 @@
+ &ifdata->tcp6_listener_watch);
+ }
+
++static const char * get_inner_ip(char* ip, char *query) {
++ int len[4]= {0};
++ char *p = query;
++ char *ret = ip;
++ char *ptr[4] = {0};
++ int i;
++ for(i=0;i<4;i++) {
++ ptr[3-i] = p;
++ p = strstr(ptr[3-i], ".");
++ if (p == NULL) {
++ break;
++ }
++ len[3-i] = p - ptr[3-i];
++ if (len[3-i] > 3) {
++ return NULL;
++ }
++ p ++;
++ }
++
++ for(i=0;i<4;i++) {
++ if (len[i] == 0)
++ return NULL;
++ }
++
++ for(i=0;i<4;i++) {
++ memcpy(ip, ptr[i], len[i]);
++ ip += len[i];
++ *ip++ = '.';
++ }
++
++ ip[-1] = '\0';
++
++ return ret;
++}
++
+ static bool udp_listener_event(GIOChannel *channel, GIOCondition condition,
+ struct listener_data *ifdata, int family,
+ guint *listener_watch)
+@@ -3574,6 +3651,7 @@
+ void *client_addr;
+ socklen_t *client_addr_len;
+ int sk, err, len;
++ char ip[16], *hostname;
+
+ if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+ connman_error("Error with UDP listener channel");
+@@ -3599,6 +3677,16 @@
+ debug("Received %d bytes (id 0x%04x)", len, buf[0] | buf[1] << 8);
+
+ err = parse_request(buf, len, query, sizeof(query));
++ get_inner_ip(ip, query);
++
++ if ((hostname = g_dhcp_server_find_hostname(ip)) != NULL) {
++
++ send_ok_response(sk, buf, len, client_addr,
++ *client_addr_len, hostname);
++ g_free(hostname);
++ return true;
++ }
++
+ if (err < 0 || (g_slist_length(server_list) == 0)) {
+ send_response(sk, buf, len, client_addr,
+ *client_addr_len, IPPROTO_UDP);
+--- connman-1.41/gdhcp/gdhcp.h 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/gdhcp/gdhcp_new.h 2022-08-27 14:14:57.787351100 +0800
+@@ -232,6 +232,7 @@
+ GDHCPSaveLeaseFunc func, gpointer user_data);
+ void g_dhcp_server_set_lease_added_cb(GDHCPServer *dhcp_server,
+ GDHCPLeaseAddedCb cb);
++char * g_dhcp_server_find_hostname(const char *ip);
+
+ #ifdef __cplusplus
+ }
+--- connman-1.41/gdhcp/server.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/gdhcp/server_new.c 2022-08-27 15:33:39.326208800 +0800
+@@ -107,13 +107,47 @@
+ return NULL;
+ }
+
++static GHashTable *cached_hostname_table = NULL;
++static int add_cached_hostname(const char * ip, const char * hostname)
++{
++ if (ip == NULL) {
++ return -1;
++ }
++ if (cached_hostname_table == NULL) {
++ cached_hostname_table = g_hash_table_new_full(g_str_hash, g_str_equal,
++ NULL, g_free);
++ }
++ return g_hash_table_insert(cached_hostname_table, g_strdup(ip), g_strdup(hostname));
++}
++
++static int delete_cached_hostname(const char * ip)
++{
++ if (cached_hostname_table != NULL) {
++ return g_hash_table_remove(cached_hostname_table, ip);
++ }
++ return -1;
++}
++char * g_dhcp_server_find_hostname(const char * ip) {
++ if (cached_hostname_table == NULL) {
++ return NULL;
++ }
++ char * hostname = g_hash_table_lookup(cached_hostname_table, ip);
++ if (hostname != NULL) {
++ return g_strdup(hostname);
++ }
++ return NULL;
++}
++
+ static void remove_lease(GDHCPServer *dhcp_server, struct dhcp_lease *lease)
+ {
++ struct in_addr addr;
++ addr.s_addr = htonl(lease->lease_nip);
+ dhcp_server->lease_list =
+ g_list_remove(dhcp_server->lease_list, lease);
+
+ g_hash_table_remove(dhcp_server->nip_lease_hash,
+ GINT_TO_POINTER((int) lease->lease_nip));
++ delete_cached_hostname(inet_ntoa(addr));
+ g_free(lease);
+ }
+
+@@ -653,6 +687,10 @@
+ uint8_t type, *server_id_option, *request_ip_option;
+ uint16_t packet_len;
+ int re;
++ const uint8_t *host_name_ptr;
++ char hostname[128] = {0};
++ struct in_addr addr;
++ char *ip = NULL;
+
+ if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+ dhcp_server->listener_watch = 0;
+@@ -664,7 +702,18 @@
+ return TRUE;
+ packet_len = (uint16_t)(unsigned int)re;
+
++ host_name_ptr = dhcp_get_option(&packet, packet_len, DHCP_HOST_NAME);
++ if (host_name_ptr != NULL) {
++ for(int i=0;i<127;i++) {
++ if( host_name_ptr[i] >= 0x20) {
++ hostname[i] = host_name_ptr[i];
++ }
++ }
++ }
++
++
+ type = check_packet_type(&packet, packet_len);
++ debug(dhcp_server, "hostname:%s, type:%d", hostname, type);
+ if (type == 0)
+ return TRUE;
+
+@@ -682,12 +731,17 @@
+ requested_nip = get_be32(request_ip_option);
+
+ lease = find_lease_by_mac(dhcp_server, packet.chaddr);
++ if (lease && lease->lease_nip != 0) {
++ addr.s_addr = htonl(lease->lease_nip);
++ ip = inet_ntoa(addr);
++ }
+
+ switch (type) {
+ case DHCPDISCOVER:
+ debug(dhcp_server, "Received DISCOVER");
+
+ send_offer(dhcp_server, &packet, lease, requested_nip);
++ add_cached_hostname(ip, hostname);
+ break;
+ case DHCPREQUEST:
+ debug(dhcp_server, "Received REQUEST NIP %d",
+@@ -702,6 +756,7 @@
+ debug(dhcp_server, "Sending ACK");
+ send_ACK(dhcp_server, &packet,
+ lease->lease_nip);
++ add_cached_hostname(ip, hostname);
+ break;
+ }
+
+@@ -743,6 +798,7 @@
+ case DHCPINFORM:
+ debug(dhcp_server, "Received INFORM");
+ send_inform(dhcp_server, &packet);
++ add_cached_hostname(ip, hostname);
+ break;
+ }
+
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_enable_ext_commands.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_enable_ext_commands.patch
new file mode 100755
index 0000000..f64347c
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_enable_ext_commands.patch
@@ -0,0 +1,34 @@
+--- connman-1.41/client/commands_old.c 2022-10-17 14:48:12.923774000 +0800
++++ connman-1.41/client/commands.c 2022-10-17 14:51:38.123907400 +0800
+@@ -2915,6 +2915,8 @@
+ return -EINVAL;
+ }
+
++#include "ext_commands.c"
++
+ static const struct {
+ const char *cmd;
+ const char *argument;
+@@ -2985,6 +2987,7 @@
+ "Exit", NULL },
+ { "quit", NULL, NULL, cmd_exit,
+ "Quit", NULL },
++ EXT_COMMANDS_DEF
+ { NULL, },
+ };
+
+--- /dev/null
++++ connman-1.41/client/ext_commands.c 2022-10-17 14:51:12.987887300 +0800
+@@ -0,0 +1,12 @@
++
++
++
++#define EXT_COMMANDS_DEF \
++ \
++
++
++
++
++
++
++
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_fix_dnsproxy_coredump.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_fix_dnsproxy_coredump.patch
new file mode 100755
index 0000000..84d693f
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_fix_dnsproxy_coredump.patch
@@ -0,0 +1,272 @@
+--- connman-1.41/src/dnsproxy.c 2022-08-27 15:39:40.864223400 +0800
++++ connman-1.41/src/dnsproxy_new.c 2022-09-20 17:31:47.064688000 +0800
+@@ -42,7 +42,8 @@
+ #include "connman.h"
+
+ #include <gdhcp/gdhcp.h>
+-#define debug(fmt...) do { } while (0)
++//#define debug(fmt,...) do { printf(fmt, __VA_ARGS__);printf("\n");} while (0)
++#define debug(fmt,...) do {} while (0)
+
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+ struct domain_hdr {
+@@ -168,6 +169,7 @@
+ uint16_t answers;
+ unsigned int data_len;
+ unsigned char *data; /* contains DNS header + body */
++ int ref_cnt;
+ };
+
+ struct cache_entry {
+@@ -225,6 +227,61 @@
+ static GHashTable *partial_tcp_req_table;
+ static guint cache_timer = 0;
+
++static void init_ref_cache_data(struct cache_data * ptr)
++{
++ if (ptr == NULL)
++ return;
++ ptr->ref_cnt = 1;
++}
++
++static void ref_cache_data(struct cache_data * ptr)
++{
++ if (ptr == NULL)
++ return;
++ ptr->ref_cnt++;
++}
++
++static void unref_cache_data(struct cache_data * ptr)
++{
++ if (ptr == NULL)
++ return;
++ ptr->ref_cnt--;
++ if (ptr->ref_cnt == 0)
++ {
++ if (ptr->data)
++ {
++ printf("%d cache %p data free %p\n", __LINE__, ptr, ptr->data);
++ g_free(ptr->data);
++ ptr->data = NULL;
++ }
++ g_free(ptr);
++ }
++}
++
++static void free_cache_data(struct cache_data ** ptr)
++{
++ struct cache_data * todo = NULL;
++ if (ptr == NULL)
++ return;
++ todo = *ptr;
++ if (todo == NULL)
++ {
++ return;
++ }
++ *ptr = NULL;
++ todo->ref_cnt --;
++ if (todo->ref_cnt > 0) {
++ return;
++ }
++ if (todo->data)
++ {
++ printf("%d cache %p data free %p\n", __LINE__, todo, todo->data);
++ g_free(todo->data);
++ todo->data = NULL;
++ }
++ g_free(todo);
++}
++
+ static guint16 get_id(void)
+ {
+ uint64_t rand;
+@@ -586,13 +643,15 @@
+ {
+ struct request_data *req = user_data;
+ struct sockaddr *sa;
+- int sk;
++ int sk, pos;
+
+ if (!req)
+ return FALSE;
+
+ debug("id 0x%04x", req->srcid);
+
++ pos = g_slist_index(request_list, req);
++
+ request_list = g_slist_remove(request_list, req);
+
+ if (req->protocol == IPPROTO_UDP) {
+@@ -640,7 +699,8 @@
+
+ out:
+ req->timeout = 0;
+- destroy_request_data(req);
++ if (pos != -1)
++ destroy_request_data(req);
+
+ return FALSE;
+ }
+@@ -722,18 +782,14 @@
+ if (!cache_check_is_valid(entry->ipv4, current_time)
+ && entry->ipv4) {
+ debug("cache timeout \"%s\" type A", entry->key);
+- g_free(entry->ipv4->data);
+- g_free(entry->ipv4);
+- entry->ipv4 = NULL;
++ free_cache_data(&entry->ipv4);
+
+ }
+
+ if (!cache_check_is_valid(entry->ipv6, current_time)
+ && entry->ipv6) {
+ debug("cache timeout \"%s\" type AAAA", entry->key);
+- g_free(entry->ipv6->data);
+- g_free(entry->ipv6);
+- entry->ipv6 = NULL;
++ free_cache_data(&entry->ipv6);
+ }
+ }
+
+@@ -799,13 +855,11 @@
+ return;
+
+ if (entry->ipv4) {
+- g_free(entry->ipv4->data);
+- g_free(entry->ipv4);
++ free_cache_data(&entry->ipv4);
+ }
+
+ if (entry->ipv6) {
+- g_free(entry->ipv6->data);
+- g_free(entry->ipv6);
++ free_cache_data(&entry->ipv6);
+ }
+
+ g_free(entry->key);
+@@ -1321,15 +1375,11 @@
+
+ /* delete the cached data */
+ if (entry->ipv4) {
+- g_free(entry->ipv4->data);
+- g_free(entry->ipv4);
+- entry->ipv4 = NULL;
++ free_cache_data(&entry->ipv4);
+ }
+
+ if (entry->ipv6) {
+- g_free(entry->ipv6->data);
+- g_free(entry->ipv6);
+- entry->ipv6 = NULL;
++ free_cache_data(&entry->ipv6);
+ }
+
+ /* keep the entry if we want it refreshed, delete it otherwise */
+@@ -1496,6 +1546,7 @@
+ cache_offset = 2;
+ data->data_len = msg_len + cache_offset;
+ data->data = ptr = g_malloc(data->data_len);
++ printf("%d cache %p data create %p\n", __LINE__, data, data->data);
+ ptr[0] = (data->data_len - 2) / 256;
+ ptr[1] = (data->data_len - 2) - ptr[0] * 256;
+ if (srv->protocol == IPPROTO_UDP)
+@@ -1503,6 +1554,7 @@
+ data->valid_until = entry->ipv4->valid_until;
+ data->cache_until = entry->ipv4->cache_until;
+ memcpy(ptr, msg, msg_len);
++ init_ref_cache_data(data);
+ entry->ipv6 = data;
+ /*
+ * we will get a "hit" when we serve the response
+@@ -1587,10 +1639,11 @@
+ * here even for UDP packet because it simplifies the sending
+ * of cached packet.
+ */
+- data->data_len = 2 + 12 + qlen + 1 + 2 + 2 + rsplen;
++ data->data_len = 2 + offset + 12 + qlen + 1 + 2 + 2 + rsplen;
+ data->data = ptr = g_malloc(data->data_len);
+ data->valid_until = current_time + ttl;
+
++ printf("%d cache %p data create %p offset %d\n", __LINE__, data, data->data, offset);
+ /*
+ * Restrict the cached DNS record TTL to some sane value
+ * in order to prevent data staying in the cache too long.
+@@ -1636,6 +1689,8 @@
+ cache_size++;
+ }
+
++ init_ref_cache_data(data);
++
+ debug("cache %d %squestion \"%s\" type %d ttl %d size %zd packet %u "
+ "dns len %u",
+ cache_size, new_entry ? "new " : "old ",
+@@ -1674,9 +1729,11 @@
+ }
+
+ if (data && req->protocol == IPPROTO_TCP) {
++ ref_cache_data(data);
+ send_cached_response(req->client_sk, data->data,
+ data->data_len, NULL, 0, IPPROTO_TCP,
+ req->srcid, data->answers, ttl_left);
++ unref_cache_data(data);
+ return 1;
+ }
+
+@@ -1686,10 +1743,12 @@
+ if (udp_sk < 0)
+ return -EIO;
+
++ ref_cache_data(data);
+ send_cached_response(udp_sk, data->data,
+ data->data_len, &req->sa, req->sa_len,
+ IPPROTO_UDP, req->srcid, data->answers,
+ ttl_left);
++ unref_cache_data(data);
+ return 1;
+ }
+ }
+@@ -1989,7 +2048,7 @@
+ {
+ struct domain_hdr *hdr;
+ struct request_data *req;
+- int dns_id, sk, err, offset = protocol_offset(protocol);
++ int dns_id, sk, pos, err, offset = protocol_offset(protocol);
+
+ if (offset < 0)
+ return offset;
+@@ -2219,6 +2278,8 @@
+ }
+ }
+
++ pos = g_slist_index(request_list, req);
++
+ request_list = g_slist_remove(request_list, req);
+
+ if (protocol == IPPROTO_UDP) {
+@@ -2243,11 +2304,13 @@
+ else
+ debug("proto %d sent %d bytes to %d", protocol, err, sk);
+
+- destroy_request_data(req);
++ if (pos != -1)
++ destroy_request_data(req);
+
+ return err;
+ }
+
++
+ static void server_destroy_socket(struct server_data *data)
+ {
+ debug("index %d server %s proto %d", data->index,
+@@ -3266,9 +3329,11 @@
+ ttl_left = data->valid_until - time(NULL);
+ entry->hits++;
+
++ ref_cache_data(data);
+ send_cached_response(client_sk, data->data,
+ data->data_len, NULL, 0, IPPROTO_TCP,
+ req->srcid, data->answers, ttl_left);
++ unref_cache_data(data);
+
+ g_free(req);
+ goto out;
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_ifconfig_cmd.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_ifconfig_cmd.patch
new file mode 100755
index 0000000..86cee4d
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_ifconfig_cmd.patch
@@ -0,0 +1,445 @@
+--- connman-1.41/src/manager.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/src/manager_new.c 2022-08-20 17:16:50.031688400 +0800
+@@ -29,6 +29,13 @@
+
+ #include <connman/agent.h>
+
++#include <stdio.h>
++#include <unistd.h>
++#include <sys/socket.h>
++#include <net/if.h>
++#include <net/if_arp.h>
++#include <sys/ioctl.h>
++
+ #include "connman.h"
+
+ static bool connman_state_idle;
+@@ -69,12 +76,61 @@
+ return reply;
+ }
+
++struct dev_info {
++ const char * dev_name;
++ char identifier[128];
++ char group[16];
++ int index;
++};
++
++void device_enum_callback (int index, void *user_data) {
++ struct dev_info * dev = (struct dev_info*)user_data;
++ unsigned short type;
++ int sock_mac;
++ struct ifreq ifr_mac;
++
++ DBG("index:%d, ptr %p", index, dev);
++ if (dev == NULL) {
++ return;
++ }
++
++ if (g_strcmp0(dev->dev_name, connman_inet_ifname(index)) == 0) {
++ type = __connman_ipconfig_get_type_from_index(index);
++ DBG("index:%d, type %d", index, type);
++ if ( type == ARPHRD_ETHER || type == ARPHRD_EETHER) {
++ sock_mac = socket( AF_INET, SOCK_STREAM, 0 );
++
++ if( sock_mac == -1) {
++ DBG("bad sock mac");
++ return;
++ }
++ strcpy(ifr_mac.ifr_name, dev->dev_name);
++ if( (ioctl( sock_mac, SIOCGIFHWADDR, &ifr_mac)) >= 0) {
++ sprintf(dev->identifier, "ethernet_%02x%02x%02x%02x%02x%02x_cable",
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[0],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[1],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[2],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[3],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[4],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[5]);
++ strcpy(dev->group, "Wired");
++ dev->index = index;
++ }
++
++ close( sock_mac );
++ }
++ }
++}
++
+ static DBusMessage *set_property(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+ {
+ DBusMessageIter iter, value;
+ const char *name;
+ int type;
++ struct dev_info dev;
++ struct connman_service * service_ptr;
++ int err = 0;
+
+ DBG("conn %p", conn);
+
+@@ -108,14 +164,105 @@
+ if (type != DBUS_TYPE_BOOLEAN)
+ return __connman_error_invalid_arguments(msg);
+
+- dbus_message_iter_get_basic(&value, &sessionmode);
+-
++ dbus_message_iter_get_basic(&value, &sessionmode);
+ } else
+ return __connman_error_invalid_property(msg);
+
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
+
++static DBusMessage *set_ipconfig(DBusConnection *conn,
++ DBusMessage *msg, void *data)
++{
++ DBusMessageIter iter, value;
++ const char *name;
++ int type;
++ struct dev_info dev;
++ struct connman_service * service_ptr;
++ int err = 0;
++
++ DBG("conn %p", conn);
++ memset(&dev, 0, sizeof (dev));
++
++ if (!dbus_message_iter_init(msg, &iter))
++ return __connman_error_invalid_arguments(msg);
++
++ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
++ return __connman_error_invalid_arguments(msg);
++
++ dbus_message_iter_get_basic(&iter, &name);
++ dbus_message_iter_next(&iter);
++
++ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
++ return __connman_error_invalid_arguments(msg);
++
++ dbus_message_iter_recurse(&iter, &value);
++
++ type = dbus_message_iter_get_arg_type(&value);
++
++ if (!g_str_equal(name, "")) {
++ dev.dev_name = name;
++ DBG("%s, %s", name, dev.dev_name);
++ __connman_ipconfig_foreach(&device_enum_callback, &dev);
++ if (dev.identifier[0] == '\0') {
++ return __connman_error_invalid_arguments(msg);
++ }
++
++ service_ptr = __connman_service_lookup_from_index(dev.index);
++
++ DBG("servcie+ptr %p", service_ptr);
++ if (service_ptr != NULL) {
++ DBG("return EEXIST");
++ return __connman_error_failed(msg, -EEXIST);
++ }
++ struct connman_ipconfig *ipconfig, *new_ipconfig;
++ enum connman_ipconfig_method old_method, new_method;
++
++ int index;
++ const char *service_identifier = dev.identifier;
++ const char* servcie_name = dev.group;
++
++ old_method = __connman_ipconfig_get_method(ipconfig);
++ index = __connman_ipconfig_get_index(ipconfig);
++
++ new_ipconfig = __connman_ipconfig_create(index,
++ CONNMAN_IPCONFIG_TYPE_IPV4);
++ if (!new_ipconfig)
++ return __connman_error_invalid_arguments(msg);
++
++ if (1) {
++ err = __connman_ipconfig_set_config(new_ipconfig, &value);
++ if (err < 0) {
++ __connman_ipconfig_unref(new_ipconfig);
++ return __connman_error_invalid_arguments(msg);
++ }
++
++ new_method = __connman_ipconfig_get_method(new_ipconfig);
++ }
++
++ GKeyFile *keyfile;
++
++ keyfile = g_key_file_new();
++ if (!keyfile)
++ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
++
++ if (servcie_name)
++ g_key_file_set_string(keyfile, service_identifier,
++ "Name", servcie_name);
++
++ if (new_ipconfig)
++ __connman_ipconfig_save(new_ipconfig, keyfile,
++ service_identifier, "IPv4.");
++
++ __connman_storage_save_service(keyfile, service_identifier);
++
++ g_key_file_free(keyfile);
++ } else
++ return __connman_error_invalid_property(msg);
++
++ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
++}
++
+ static void append_technology_structs(DBusMessageIter *iter, void *user_data)
+ {
+ __connman_technology_list_struct(iter);
+@@ -582,7 +729,10 @@
+ register_peer_service) },
+ { GDBUS_METHOD("UnregisterPeerService",
+ GDBUS_ARGS({ "specification", "a{sv}" }), NULL,
+- unregister_peer_service) },
++ unregister_peer_service) },
++ { GDBUS_METHOD("SetIPConfig",
++ GDBUS_ARGS({ "name", "s" }, { "value", "v" }),
++ NULL, set_ipconfig) },
+ { },
+ };
+
+--- connman-1.41/client/commands.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/client/commands_new.c 2022-08-20 18:37:54.452762100 +0800
+@@ -45,6 +45,11 @@
+ #include "agent.h"
+ #include "vpnconnections.h"
+
++#include <sys/socket.h>
++#include <net/if.h>
++#include <net/if_arp.h>
++#include <sys/ioctl.h>
++
+ static DBusConnection *connection;
+ static GHashTable *service_hash;
+ static GHashTable *vpnconnection_hash;
+@@ -980,6 +985,12 @@
+ struct connman_option *options;
+ };
+
++struct ipconfig_options {
++ char *service_name;
++ char *ipconfig_cmd;
++ struct config_append append;
++};
++
+ static void config_append_ipv4(DBusMessageIter *iter,
+ void *user_data)
+ {
+@@ -999,6 +1010,59 @@
+ append->values = i;
+ }
+
++static int ipconfig_return(DBusMessageIter *iter, int errnum,
++ const char *error, void *user_data)
++{
++ struct ipconfig_options * config = user_data;
++
++ char * path;
++ int sock_mac;
++ struct ifreq ifr_mac;
++ char identifier[64];
++
++// printf("ipconfig_return %d %s\n", errnum, error);
++ if (errnum == -EEXIST || (error && strstr(error, "-17") != NULL)) {
++// printf("exits service\n");
++ sock_mac = socket( AF_INET, SOCK_STREAM, 0 );
++
++ if( sock_mac == -1) {
++ return -1;
++ }
++
++ strcpy(ifr_mac.ifr_name, config->service_name);
++ if( (ioctl( sock_mac, SIOCGIFHWADDR, &ifr_mac)) >= 0) {
++ sprintf(identifier, "ethernet_%02x%02x%02x%02x%02x%02x_cable",
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[0],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[1],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[2],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[3],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[4],
++ (unsigned char)ifr_mac.ifr_hwaddr.sa_data[5]);
++ }
++
++ close( sock_mac );
++
++ path = g_strdup_printf("/net/connman/service/%s", identifier);
++ //printf("service name %s\n", identifier);
++ __connmanctl_dbus_set_property_dict(connection,
++ path, "net.connman.Service",
++ config_return, g_strdup(identifier),
++ "IPv4.Configuration", DBUS_TYPE_STRING,
++ config_append_ipv4, &config->append);
++ }
++ else if (error)
++ fprintf(stderr, "Error %s: %s\n", config->service_name, error);
++ else if (config->ipconfig_cmd) {
++ system(config->ipconfig_cmd);
++ g_free(config->ipconfig_cmd);
++ }
++
++ g_free(config->service_name);
++ g_free(user_data);
++
++ return 0;
++}
++
+ static void config_append_ipv6(DBusMessageIter *iter, void *user_data)
+ {
+ struct config_append *append = user_data;
+@@ -1327,6 +1391,78 @@
+ return result;
+ }
+
++static int cmd_ipconfig(char *args[], int num, struct connman_option *options)
++{
++ int result = 0, res = 0, index = 2, oldindex = 0;
++ int c;
++ char *service_name, *path;
++ char **opt_start;
++ struct config_append append;
++ struct ipconfig_options *ipconfig_ptr;
++
++ service_name = args[1];
++ if (!service_name)
++ return -EINVAL;
++// printf("ifconfig name %s\n", service_name);
++
++ while (index < num && args[index]) {
++ c = parse_args(args[index], options);
++ opt_start = &args[index + 1];
++ append.opts = opt_start;
++ append.values = 0;
++ ipconfig_ptr = g_new0(struct ipconfig_options, 1);
++ ipconfig_ptr->service_name = g_strdup(service_name);
++ ipconfig_ptr->ipconfig_cmd = NULL;
++ ipconfig_ptr->append.opts = opt_start;
++ ipconfig_ptr->append.values = 0;
++
++ res = 0;
++
++ oldindex = index;
++ path = g_strdup_printf("/");
++
++ switch (c) {
++ case 'i':
++ {
++ if (num > 4 && strcmp(args[2], "--ipv4") == 0 && strcmp(args[3], "manual") == 0) {
++ if (num > 5)
++ ipconfig_ptr->ipconfig_cmd = g_strdup_printf("ifconfig %s %s netmask %s", service_name, args[4], args[5]);
++ else
++ ipconfig_ptr->ipconfig_cmd = g_strdup_printf("ifconfig %s %s", service_name, args[4]);
++ }
++ res = __connmanctl_dbus_method_call_with_name(connection,
++ "net.connman", path, "net.connman.Manager", "SetIPConfig",
++ ipconfig_return, ipconfig_ptr,
++ service_name, DBUS_TYPE_STRING,
++ config_append_ipv4, &append);
++
++// printf("res is %d\n", res);
++ index += append.values;
++ break;
++ }
++
++ default:
++ res = -EINVAL;
++ break;
++ }
++
++ g_free(path);
++
++ if (res < 0) {
++ if (res == -EINPROGRESS)
++ result = -EINPROGRESS;
++ else
++ printf("Error '%s': %s\n", args[oldindex],
++ strerror(-res));
++ } else
++ index += res;
++
++ index++;
++ }
++
++ return result;
++}
++
+ static DBusHandlerResult monitor_changed(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+ {
+@@ -2825,6 +2961,8 @@
+ lookup_service_arg },
+ { "config", "<service>", config_options, cmd_config,
+ "Set service configuration options", lookup_config },
++ { "ifconfig", "<interface>", config_options, cmd_ipconfig,
++ "Set interface configuration options", lookup_config },
+ { "monitor", "[off]", monitor_options, cmd_monitor,
+ "Monitor signals from interfaces", lookup_monitor },
+ { "agent", "on|off", NULL, cmd_agent,
+--- connman-1.41/client/dbus_helpers.h 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/client/dbus_helpers_new.h 2022-08-20 17:17:32.301009500 +0800
+@@ -49,6 +49,14 @@
+ void * user_data, connmanctl_dbus_append_func_t append_fn,
+ void *append_data);
+
++int __connmanctl_dbus_method_call_with_name(DBusConnection *connection,
++ const char *service, const char *path,
++ const char *interface, const char *method,
++ connmanctl_dbus_method_return_func_t cb, void * user_data,
++ const char *property, int type,
++ connmanctl_dbus_append_func_t append_fn,
++ void *append_data);
++
+ int __connmanctl_dbus_set_property(DBusConnection *connection,
+ const char *path, const char *interface,
+ connmanctl_dbus_method_return_func_t cb, void * user_data,
+--- connman-1.41/client/dbus_helpers.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/client/dbus_helpers_new.c 2022-08-20 17:54:29.303478800 +0800
+@@ -289,6 +289,52 @@
+ return send_method_call(connection, message, cb, user_data);
+ }
+
++int __connmanctl_dbus_method_call_with_name(DBusConnection *connection,
++ const char *service, const char *path,
++ const char *interface, const char *method,
++ connmanctl_dbus_method_return_func_t cb, void * user_data,
++ const char *property, int type,
++ connmanctl_dbus_append_func_t append_fn,
++ void *append_data)
++{
++ DBusMessage *message;
++ DBusMessageIter iter, variant, dict;
++
++ message = dbus_message_new_method_call(service, path, interface,
++ method);
++
++ if (!message)
++ return -ENOMEM;
++
++ //printf("set property path:%s,interface:%s\n", path, interface);
++ if (!message)
++ return -ENOMEM;
++
++ dbus_message_iter_init_append(message, &iter);
++ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &property);
++ dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
++ DBUS_TYPE_ARRAY_AS_STRING
++ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
++ DBUS_TYPE_STRING_AS_STRING
++ DBUS_TYPE_VARIANT_AS_STRING
++ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
++ &variant);
++
++ dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY,
++ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
++ DBUS_TYPE_STRING_AS_STRING
++ DBUS_TYPE_VARIANT_AS_STRING
++ DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
++ &dict);
++
++ append_fn(&dict, append_data);
++
++ dbus_message_iter_close_container(&variant, &dict);
++ dbus_message_iter_close_container(&iter, &variant);
++
++ return send_method_call(connection, message, cb, user_data);
++}
++
+ int __connmanctl_dbus_set_property(DBusConnection *connection,
+ const char *path, const char *interface,
+ connmanctl_dbus_method_return_func_t cb, void * user_data,
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_oem_commands.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_oem_commands.patch
new file mode 100755
index 0000000..d6909c6
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_oem_commands.patch
@@ -0,0 +1,183 @@
+--- connman-1.41/client/ext_commands_old.c 2022-10-17 15:11:37.646122900 +0800
++++ connman-1.41/client/ext_commands.c 2022-10-18 14:31:00.112375700 +0800
+@@ -1,12 +1,73 @@
+
+
++static int oem_cmd_return(DBusMessageIter *iter, int errnum,
++ const char *error, void *user_data)
++{
++// printf("oemcmd return\n");
++ if (error)
++ fprintf(stderr, "Error %s\n", error);
++ else{
++ fprintf(stdout, "OK\n");
++ }
++
++ return 0;
++}
++
++static void append_args(DBusMessageIter *iter, void *user_data)
++{
++ DBusMessageIter array;
++ struct config_append *append = user_data;
++ char **opts = append->opts;
++ int index;
++
++ if (!opts)
++ return;
++
++ dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
++ DBUS_TYPE_STRING_AS_STRING, &array);
++
++ for(index=0; index < append->values; index++)
++ {
++// printf("----to append %s\n", opts[index]);
++ dbus_message_iter_append_basic(&array,
++ DBUS_TYPE_STRING, &opts[index]);
++ }
++
++ dbus_message_iter_close_container(iter, &array);
++}
++
++static int cmd_oem_cmd(char *args[], int num, struct connman_option *options)
++{
++ int result = 0, res = 0;
++ char * cmd;
++ struct config_append append;
++ if (num < 2) {
++ return -EINVAL;
++ }
++
++ cmd = g_strdup(args[1]);
++ cmd[0] = toupper(cmd[0]);
++ append.opts = &args[2];
++// printf("total %d\n", num);
++ append.values = num - 2;
++ res = __connmanctl_dbus_method_call(connection,
++ "net.connman", "/", "net.connman.Manager", cmd,
++ oem_cmd_return, NULL,
++ append_args, &append);
++
++ if (res < 0) {
++ if (res == -EINPROGRESS)
++ result = -EINPROGRESS;
++ else
++ printf("Error : %s\n", strerror(-res));
++ }
++
++ g_free(cmd);
++ return result;
++}
+
+ #define EXT_COMMANDS_DEF \
++ { "oem_cmd", "<command>", NULL, cmd_oem_cmd,\
++ "To call oem commands", NULL }, \
+ \
+
+-
+-
+-
+-
+-
+-
+--- connman-1.41/src/manager_old.c 2022-10-17 15:11:37.498121000 +0800
++++ connman-1.41/src/manager.c 2022-10-18 14:33:10.509668100 +0800
+@@ -263,6 +263,88 @@
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
+
++static DBusMessage *cmd_tether(DBusConnection *conn,
++ DBusMessage *msg, void *data)
++{
++ DBusMessageIter iter, array;
++ const char *interface, *on_of_flag, *subnet_mask;
++ int index, prefixlen;
++ struct connman_service * service_ptr;
++ struct in_addr ip_address;
++ int err = 0;
++
++ DBG("conn %p", conn);
++
++ if (!dbus_message_iter_init(msg, &iter))
++ return __connman_error_invalid_arguments(msg);
++
++ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
++ return __connman_error_invalid_arguments(msg);
++ printf("arg type %d\n",dbus_message_iter_get_arg_type(&iter));
++
++ dbus_message_iter_recurse(&iter, &array);
++ printf("array got %d\n",dbus_message_iter_get_arg_type(&array));
++ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRING)
++ return __connman_error_invalid_arguments(msg);
++
++// dbus_message_iter_get_basic(&iter, &interface);
++ dbus_message_iter_get_basic(&array, &interface);
++ printf("arg type2 %d\n",dbus_message_iter_get_arg_type(&array));
++ dbus_message_iter_next(&array);
++ printf("interface %s\n", interface);
++
++ if (strcmp(interface, "tether") == 0) {
++ return __connman_error_invalid_arguments(msg);
++ }
++
++ index = connman_inet_ifindex(interface);
++ if (index < 0) {
++ return __connman_error_failed(msg,ENXIO);
++ }
++
++ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRING)
++ return __connman_error_invalid_arguments(msg);
++ dbus_message_iter_get_basic(&array, &on_of_flag);
++ dbus_message_iter_next(&array);
++ printf("on-of %s\n", on_of_flag);
++
++ if (strcasecmp(on_of_flag, "OFF") == 0)
++ {
++
++ __connman_dnsproxy_remove_listener(index);
++ __connman_nat_disable(interface);
++ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
++ }
++ else if (strcasecmp(on_of_flag, "ON") != 0)
++ {
++ return __connman_error_invalid_arguments(msg);
++ }
++
++ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRING)
++ return __connman_error_invalid_arguments(msg);
++ dbus_message_iter_get_basic(&array, &subnet_mask);
++ dbus_message_iter_next(&array);
++
++// ip_address = g_try_new0(struct in_addr, 1);
++ memset(&ip_address, 0, sizeof (struct in_addr));
++ __connman_inet_get_interface_address(index, AF_INET, &ip_address);
++ printf("ipaddr is %s\n", inet_ntoa(ip_address));
++
++ __connman_dnsproxy_remove_listener(index);
++ err = __connman_dnsproxy_add_listener(index);
++ if (err < 0) {
++ return __connman_error_failed(msg,err);
++ }
++
++ printf("subnet mask %s\n", subnet_mask);
++ prefixlen = connman_ipaddress_calc_netmask_len(subnet_mask);
++
++ __connman_nat_disable(interface);
++ err = __connman_nat_enable(interface, inet_ntoa(ip_address), prefixlen);
++
++ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
++}
++
+ static void append_technology_structs(DBusMessageIter *iter, void *user_data)
+ {
+ __connman_technology_list_struct(iter);
+@@ -733,6 +815,9 @@
+ { GDBUS_METHOD("SetIPConfig",
+ GDBUS_ARGS({ "name", "s" }, { "value", "v" }),
+ NULL, set_ipconfig) },
++ { GDBUS_METHOD("Tether",
++ GDBUS_ARGS({ "params", "as" }),
++ NULL, cmd_tether) },
+ { },
+ };
+
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_ap_sta.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_ap_sta.patch
index 855cbf1..d8b7e76 100755
--- a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_ap_sta.patch
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_ap_sta.patch
@@ -1,14 +1,14 @@
---- connman-1.35/plugins/wifi.c 2022-04-30 14:31:30.777805400 +0800
-+++ connman-1.35/plugins/wifi_new.c 2022-05-12 17:54:35.727120400 +0800
-@@ -153,6 +153,7 @@
+--- connman-1.41/plugins/wifi.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/plugins/wifi_new.c 2022-05-12 09:03:27.544623700 +0800
+@@ -164,6 +164,7 @@
int servicing;
int disconnect_code;
int assoc_code;
+ bool interface_create_flag;
};
- static GList *iface_list = NULL;
-@@ -784,6 +785,7 @@
+ struct wifi_network {
+@@ -808,6 +809,7 @@
else
iface_list = g_list_append(iface_list, wifi);
@@ -16,9 +16,64 @@
return 0;
}
-@@ -1471,13 +1473,13 @@
+@@ -816,6 +818,7 @@
{
+ GSList *list;
+
++ DBG("cy-remove_networks device %p, wifi %p", device, wifi);
+ for (list = wifi->networks; list; list = list->next) {
+ struct connman_network *network = list->data;
+
+@@ -1420,11 +1423,21 @@
+ {
+ struct wifi_data *wifi = connman_device_get_data(device);
+ struct autoscan_params *autoscan;
++ struct wifi_data *wifi2;
++ GList *list;
+
+ DBG("");
+
++ for (list = iface_list; list; list = list->next) {
++ wifi2 = list->data;
++
++ DBG("cy-wifi %p network %p interface %p", wifi2,
++ wifi2->network, wifi2->interface);
++ }
+ if (!wifi)
+ return;
++ else
++ return;
+
+ if (wifi->p2p_device)
+ return;
+@@ -1535,10 +1548,10 @@
+ if (wifi->p2p_device)
+ return;
+
+- if (!wifi->autoscan)
+- setup_autoscan(wifi);
++ // if (!wifi->autoscan)
++ // setup_autoscan(wifi);
+
+- start_autoscan(wifi->device);
++ // start_autoscan(wifi->device);
+ }
+
+ static void interface_create_callback(int result,
+@@ -1548,14 +1561,24 @@
struct wifi_data *wifi = user_data;
+ char *bgscan_range_max;
+ long value;
++ struct wifi_data *wifi2=NULL;
++
++ GList *list;
++
++ for (list = iface_list; list; list = list->next) {
++ wifi2 = list->data;
++
++ DBG("cy-wifi %p network %p interface %p", wifi2,
++ wifi2->network, wifi2->interface);
++ }
- DBG("result %d ifname %s, wifi %p", result,
+ DBG("cy-result %d ifname %s, wifi %p, %s", result,
@@ -34,8 +89,8 @@
wifi->interface = interface;
g_supplicant_interface_set_data(interface, wifi);
-@@ -1495,7 +1497,8 @@
- const char *driver = connman_option_get_string("wifi");
+@@ -1591,7 +1614,8 @@
+ const char *driver = connman_setting_get_string("wifi");
int ret;
- DBG("device %p %p", device, wifi);
@@ -44,7 +99,7 @@
index = connman_device_get_index(device);
if (!wifi || index < 0)
-@@ -1505,6 +1508,13 @@
+@@ -1601,14 +1625,24 @@
return -EINPROGRESS;
interface = connman_inet_ifname(index);
@@ -58,14 +113,68 @@
ret = g_supplicant_interface_create(interface, driver, NULL,
interface_create_callback,
wifi);
-@@ -3103,21 +3113,21 @@
+ g_free(interface);
+
+- if (ret < 0)
++ if (ret < 0) {
++ DBG("cy-return not in progress %d", ret);
+ return ret;
++ }
+
++ DBG("cy-return -EINPROGRESS");
+ return -EINPROGRESS;
+ }
+
+@@ -2632,13 +2666,13 @@
+ }
+ wifi->disconnecting = false;
+
+- start_autoscan(device);
++ // start_autoscan(device);
+
+ break;
+
+ case G_SUPPLICANT_STATE_INACTIVE:
+ connman_network_set_associating(network, false);
+- start_autoscan(device);
++ // start_autoscan(device);
+
+ break;
+
+@@ -2674,8 +2708,8 @@
+ case G_SUPPLICANT_STATE_SCANNING:
+ wifi->connected = false;
+
+- if (old_connected)
+- start_autoscan(device);
++ // if (old_connected)
++ // start_autoscan(device);
+ break;
+ case G_SUPPLICANT_STATE_COMPLETED:
+ wifi->connected = true;
+@@ -3344,31 +3378,31 @@
+ if (!ap)
return NULL;
+- ret = connman_technology_get_wifi_tethering(technology,
+- &ssid, &passphrase,
+- &freq);
+- if (ret == false)
+- return NULL;
++ // ret = connman_technology_get_wifi_tethering(technology,
++ // &ssid, &passphrase,
++ // &freq);
++ // if (ret == false)
++ // return NULL;
+
ap->mode = G_SUPPLICANT_MODE_MASTER;
- ap->ssid = ssid;
- ap->ssid_len = strlen(ssid);
- ap->scan_ssid = 0;
-- ap->freq = 2412;
+- if (freq)
+- ap->freq = freq;
+- else
+- ap->freq = 2412;
-
- if (!passphrase || strlen(passphrase) == 0) {
- ap->security = G_SUPPLICANT_SECURITY_NONE;
@@ -80,7 +189,10 @@
+ // ap->ssid = ssid;
+ // ap->ssid_len = strlen(ssid);
+ // ap->scan_ssid = 0;
-+ // ap->freq = 2412;
++ // if (freq)
++ // ap->freq = freq;
++ // else
++ // ap->freq = 2412;
+
+ // if (!passphrase || strlen(passphrase) == 0) {
+ // ap->security = G_SUPPLICANT_SECURITY_NONE;
@@ -95,7 +207,7 @@
return ap;
}
-@@ -3179,8 +3189,8 @@
+@@ -3430,8 +3464,8 @@
if (g_supplicant_interface_set_apscan(interface, 2) < 0)
connman_error("Failed to set interface ap_scan property");
@@ -106,7 +218,13 @@
}
static void sta_remove_callback(int result,
-@@ -3235,13 +3245,23 @@
+@@ -3480,18 +3514,28 @@
+ for (list = iface_list; list; list = list->next) {
+ wifi = list->data;
+
+- DBG("wifi %p network %p pending_network %p", wifi,
++ DBG("cy-wifi %p network %p pending_network %p", wifi,
+ wifi->network, wifi->pending_network);
interface = wifi->interface;
@@ -133,7 +251,7 @@
if (wifi->ap_supported == WIFI_AP_NOT_SUPPORTED) {
DBG("%s does not support AP mode (detected)", ifname);
continue;
-@@ -3256,6 +3276,7 @@
+@@ -3506,6 +3550,7 @@
if (wifi->network && available)
continue;
@@ -141,7 +259,7 @@
info = g_try_malloc0(sizeof(struct wifi_tethering_info));
if (!info)
-@@ -3288,9 +3309,11 @@
+@@ -3538,9 +3583,11 @@
if (berr < 0)
goto failed;
@@ -156,9 +274,17 @@
if (err >= 0) {
DBG("tethering wifi %p ifname %s", wifi, ifname);
return 0;
---- connman-1.35/gsupplicant/supplicant.c 2017-08-11 02:56:43.000000000 +0800
-+++ connman-1.35/gsupplicant/supplicant_new.c 2022-05-12 15:36:33.433705200 +0800
-@@ -3869,6 +3869,15 @@
+--- connman-1.41/gsupplicant/supplicant.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/gsupplicant/supplicant_new.c 2022-05-11 18:01:51.174203200 +0800
+@@ -3638,6 +3638,7 @@
+ if (!path)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
++ SUPPLICANT_DBG("cy- msg %s", path);
+ if (!dbus_message_iter_init(message, &iter))
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+@@ -4005,6 +4006,15 @@
DBUS_TYPE_STRING, &data->bridge);
config_file = g_hash_table_lookup(config_file_table, data->ifname);
@@ -174,3 +300,18 @@
if (config_file) {
SUPPLICANT_DBG("[%s] ConfigFile %s", data->ifname, config_file);
+--- connman-1.41/src/technology.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/src/technology_new.c 2022-05-11 19:23:17.729723700 +0800
+@@ -261,9 +261,9 @@
+ if (!bridge)
+ return -EOPNOTSUPP;
+
+- if (technology->type == CONNMAN_SERVICE_TYPE_WIFI &&
+- (!ident || !passphrase))
+- return -EINVAL;
++ // if (technology->type == CONNMAN_SERVICE_TYPE_WIFI &&
++ // (!ident || !passphrase))
++ // return -EINVAL;
+
+ for (tech_drivers = technology->driver_list; tech_drivers;
+ tech_drivers = g_slist_next(tech_drivers)) {
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_netmask.patch b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_netmask.patch
new file mode 100755
index 0000000..a3bc18d
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/lynq_wifi_netmask.patch
@@ -0,0 +1,147 @@
+--- connman-1.41/src/ippool.c 2022-01-28 22:48:01.000000000 +0800
++++ connman-1.41/src/ippool_new.c 2022-07-01 19:19:49.209647300 +0800
+@@ -321,6 +321,132 @@
+ g_free(info);
+ }
+
++static struct connman_ippool *__connman_ippool_create_special(int index,
++ unsigned int start,
++ unsigned int range,
++ ippool_collision_cb_t collision_cb,
++ void *user_data)
++{
++ struct connman_ippool *pool;
++ struct address_info *info;
++ uint32_t block;
++ FILE * fp;
++ char *buff, *p;
++ int i,len,mask_cnt,mask_range,mask;
++
++ DBG("");
++
++ fp = fopen("/etc/config/wifi_network", "rb");
++ if (NULL == fp) {
++ return NULL;
++ }
++
++ buff = malloc(1024);
++ len = fread(buff, 1, 1024, fp);
++ fclose(fp);
++ buff[len] = '\0';
++ connman_error("read cnt: %d\n", len);
++
++ connman_error("read: %s\n", buff);
++
++ p = NULL;
++ for(i=0; i<len; i++) {
++ if (buff[i] == '/') {
++ if (p != NULL) {
++ p = NULL;
++ break;
++ }
++ connman_error("left: %s\n", buff + i);
++ buff[i] = '\0';
++ p=buff + i + 1;
++ connman_warn("find %s\n",p);
++ }
++ else if (buff[i] == ' ') {
++ buff[i] = '\0';
++ if (p != NULL && p == buff + i) {
++ p++;
++ }
++ }
++ }
++
++ if (p == NULL) {
++ free(buff);
++ return NULL;
++ }
++
++ block = ntohl(inet_addr(buff));
++ mask_cnt = atoi(p);
++ i = mask_cnt - 24;
++ mask_range = 0xff >> i;
++ sprintf(buff, "255.255.255.%d", (mask_range<<i));
++ connman_warn("netmask %s\n",buff);
++ mask = ntohl(inet_addr(buff));
++
++ free(buff);
++ if (mask_cnt < 24 || mask_cnt >= 32) {
++ return NULL;
++ }
++
++ if (start + range > mask_range ) {
++ range = mask_range - start - 1;
++ }
++
++ /*
++ * The range is at max 255 and we don't support overlapping
++ * blocks.
++ */
++ if (start + range > 254) {
++ connman_error("IP pool does not support pool size larger than 254");
++ return NULL;
++ }
++
++ if (block == 0) {
++ connman_warn("Could not find a free IP block");
++ return NULL;
++ }
++
++ pool = g_try_new0(struct connman_ippool, 1);
++ if (!pool)
++ return NULL;
++
++ info = g_try_new0(struct address_info, 1);
++ if (!info) {
++ g_free(pool);
++ return NULL;
++ }
++
++ last_block = block;
++
++ info->index = index;
++ info->start = block;
++ info->end = block + range;
++
++ pool->info = info;
++ pool->collision_cb = collision_cb;
++ pool->user_data = user_data;
++
++ info->pool = pool;
++
++ if (range == 0)
++ range = 1;
++
++ pool->gateway = get_ip(info->start + 1);
++ pool->broadcast = get_ip(info->start + mask_range);
++ pool->subnet_mask = get_ip(mask);
++ pool->start_ip = get_ip(block + start);
++ pool->end_ip = get_ip(block + start + range);
++ connman_warn("gateway %s\n",pool->gateway);
++ connman_warn("broadcast %s\n",pool->broadcast);
++ connman_warn("subnet_mask %s\n",pool->subnet_mask);
++ connman_warn("start_ip %s\n",pool->start_ip);
++ connman_warn("end_ip %s\n",pool->end_ip);
++
++
++ allocated_blocks = g_slist_prepend(allocated_blocks, info);
++
++ return pool;
++}
++
+ struct connman_ippool *__connman_ippool_create(int index,
+ unsigned int start,
+ unsigned int range,
+@@ -333,6 +459,11 @@
+
+ DBG("");
+
++ pool = __connman_ippool_create_special(index, start, range, collision_cb, user_data);
++ if (pool != NULL) {
++ return pool;
++ }
++
+ /*
+ * The range is at max 255 and we don't support overlapping
+ * blocks.
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/main.conf b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/main.conf
new file mode 100755
index 0000000..d9e256b
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman/main.conf
@@ -0,0 +1,31 @@
+[General]
+
+# List of preferred technologies from the most preferred
+# one to the least preferred one separated by commas ",".
+# Services of the listed technology type will be tried one
+# by one in the order given, until one of them gets connected
+# or they are all tried. A service of a preferred technology
+# type in state 'ready' will get the default route when
+# compared to another preferred type further down the list
+# with state 'ready' or with a non-preferred type; a service
+# of a preferred technology type in state 'online' will get
+# the default route when compared to either a non-preferred
+# type or a preferred type further down in the list.
+PreferredTechnologies = wifi,cellular,ethernet
+
+# List of blacklisted network interfaces separated by ",".
+# Found interfaces will be compared to the list and will
+# not be handled by ConnMan, if their first characters
+# match any of the list entries. Default value is
+# vmnet,vboxnet,virbr,ifb,ve-,vb-.
+NetworkInterfaceBlacklist = vmnet,vboxnet,virbr,ifb,ve-,vb-,eth2.
+
+# Enable use of http get as on online status check.
+# When a service is in a READY state, and is selected as default,
+# ConnMan will issue an HTTP GET request to verify that end-to-end
+# connectivity is successful. Only then the service will be
+# transitioned to ONLINE state.
+# If this setting is false, the default service will remain in READY state.
+# Default value is true.
+EnableOnlineCheck = false
+
diff --git a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman_%.bbappend b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman_%.bbappend
index 76c88a5..2af6666 100755
--- a/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman_%.bbappend
+++ b/meta/meta-mediatek-mt2735/recipes-connectivity/connman/connman_%.bbappend
@@ -2,5 +2,17 @@
SRC_URI += "\
file://lynq_wifi_ap_sta.patch \
+ file://lynq_wifi_netmask.patch \
+ file://lynq_ifconfig_cmd.patch \
+ file://lynq_ap_cache_hostname.patch \
+ file://lynq_fix_dnsproxy_coredump.patch \
+ file://lynq_enable_ext_commands.patch \
+ file://lynq_oem_commands.patch \
+ file://main.conf \
"
+do_install_append() {
+ install -d ${D}${sysconfdir}/connman
+ install -m 0644 ${WORKDIR}/main.conf ${D}${sysconfdir}/connman/main.conf
+}
+
diff --git a/meta/meta-mediatek-mt2735/recipes-kernel/linux/linux-mtk-extension_4.19.bbappend b/meta/meta-mediatek-mt2735/recipes-kernel/linux/linux-mtk-extension_4.19.bbappend
old mode 100644
new mode 100755
index e79aee0..54cebb5
--- a/meta/meta-mediatek-mt2735/recipes-kernel/linux/linux-mtk-extension_4.19.bbappend
+++ b/meta/meta-mediatek-mt2735/recipes-kernel/linux/linux-mtk-extension_4.19.bbappend
@@ -92,6 +92,11 @@
install -d ${DEPLOY_DIR_IMAGE_ROOT}/sdk/src/kernel/modules
cp -Rf ${KERNEL_SRC}/* ${DEPLOY_DIR_IMAGE_ROOT}/sdk/src/kernel/linux/v4.19/
cp -Rf ${MODULES_SRC}/* ${DEPLOY_DIR_IMAGE_ROOT}/sdk/src/kernel/modules/
+ if [ "${MOBILETEK_WIFIKERNELCODE_CFG}" = "GSW" ]; then
+ rm -rf ${DEPLOY_DIR_IMAGE_ROOT}/sdk/src/kernel/linux/v4.19/drivers/net/wireless/bcmdhd
+ sed -i '/bcmdhd\//d' ${DEPLOY_DIR_IMAGE_ROOT}/sdk/src/kernel/linux/v4.19/drivers/net/wireless/Kconfig
+ sed -i '/bcmdhd\//d' ${DEPLOY_DIR_IMAGE_ROOT}/sdk/src/kernel/linux/v4.19/drivers/net/wireless/Makefile
+ fi
}
diff --git a/meta/meta-mediatek-mt2735/recipes-kernel/modules/files/wifi/wg870/cyw989570fcref_rev1.58.txt b/meta/meta-mediatek-mt2735/recipes-kernel/modules/files/wifi/wg870/cyw989570fcref_rev1.58.txt
index 8203d9c..805b986 100755
--- a/meta/meta-mediatek-mt2735/recipes-kernel/modules/files/wifi/wg870/cyw989570fcref_rev1.58.txt
+++ b/meta/meta-mediatek-mt2735/recipes-kernel/modules/files/wifi/wg870/cyw989570fcref_rev1.58.txt
@@ -10,7 +10,7 @@
macaddr=00:90:4c:2f:70:01
#Regulatory specific
-ccode=0
+ccode=CN
regrev=0
# Board specific
diff --git a/meta/poky/meta/recipes-connectivity/connman/connman.inc b/meta/poky/meta/recipes-connectivity/connman/connman.inc
index 961a5da..f7e4749 100755
--- a/meta/poky/meta/recipes-connectivity/connman/connman.inc
+++ b/meta/poky/meta/recipes-connectivity/connman/connman.inc
@@ -15,7 +15,7 @@
inherit autotools pkgconfig systemd update-rc.d bluetooth update-alternatives
-DEPENDS = "dbus glib-2.0 ppp readline"
+DEPENDS = "dbus glib-2.0 ppp readline libmnl"
INC_PR = "r20"
@@ -159,6 +159,7 @@
${sysconfdir} ${sharedstatedir} ${localstatedir} \
${base_bindir}/* ${base_sbindir}/* ${base_libdir}/*.so* ${datadir}/${PN} \
${datadir}/dbus-1/system-services/* \
+ ${datadir}/dbus-1/system.d/connman.conf \
${sysconfdir}/tmpfiles.d/connman_resolvconf.conf"
FILES_${PN}-dev += "${libdir}/connman/*/*.la"
@@ -173,7 +174,7 @@
provides a DBus API for managing VPN connections. All the different \
VPN technogies are implemented using plug-ins."
FILES_${PN}-vpn += "${sbindir}/connman-vpnd \
- ${sysconfdir}/dbus-1/system.d/connman-vpn-dbus.conf \
+ ${datadir}/dbus-1/system.d/connman-vpn-dbus.conf \
${datadir}/dbus-1/system-services/net.connman.vpn.service \
${systemd_unitdir}/system/connman-vpn.service"
diff --git a/meta/poky/meta/recipes-connectivity/connman/connman_1.35.bb b/meta/poky/meta/recipes-connectivity/connman/connman_1.35.bb
deleted file mode 100644
index ff21181..0000000
--- a/meta/poky/meta/recipes-connectivity/connman/connman_1.35.bb
+++ /dev/null
@@ -1,22 +0,0 @@
-require connman.inc
-
-SRC_URI = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
- file://0001-plugin.h-Change-visibility-to-default-for-debug-symb.patch \
- file://0001-connman.service-stop-systemd-resolved-when-we-use-co.patch \
- file://connman \
- file://no-version-scripts.patch \
- file://includes.patch \
- file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \
- file://0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch \
- file://0001-inet-Add-prefixlen-to-iproute_default_function.patch \
- file://0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch \
- file://0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch \
- file://0004-session-Use-subnet-route-creation-and-deletion-APIs.patch \
- "
-SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \
- "
-
-SRC_URI[md5sum] = "bae37b45ee9b3db5ec8115188f8a7652"
-SRC_URI[sha256sum] = "66d7deb98371545c6e417239a9b3b3e3201c1529d08eedf40afbc859842cf2aa"
-
-RRECOMMENDS_${PN} = "connman-conf"
diff --git a/meta/poky/meta/recipes-connectivity/connman/connman_1.41.bb b/meta/poky/meta/recipes-connectivity/connman/connman_1.41.bb
new file mode 100755
index 0000000..fba966f
--- /dev/null
+++ b/meta/poky/meta/recipes-connectivity/connman/connman_1.41.bb
@@ -0,0 +1,11 @@
+require connman.inc
+
+SRC_URI = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
+ "
+SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \
+ "
+
+SRC_URI[md5sum] = "7f0a05fef485d3679cd73c8808f763f9"
+SRC_URI[sha256sum] = "79fb40f4fdd5530c45aa8e592fb16ba23d3674f3a98cf10b89a6576f198de589"
+
+RRECOMMENDS_${PN} = "connman-conf"
diff --git a/meta/poky/meta/recipes-connectivity/openssh/openssh_7.8p1+git.bb b/meta/poky/meta/recipes-connectivity/openssh/openssh_7.8p1+git.bb
old mode 100644
new mode 100755
index f54dfb5..3b84850
--- a/meta/poky/meta/recipes-connectivity/openssh/openssh_7.8p1+git.bb
+++ b/meta/poky/meta/recipes-connectivity/openssh/openssh_7.8p1+git.bb
@@ -34,14 +34,41 @@
inherit useradd update-rc.d update-alternatives systemd
-USERADD_PACKAGES = "${PN}-sshd"
-USERADD_PARAM_${PN}-sshd = "--system --no-create-home --home-dir /var/run/sshd --shell /bin/false --user-group sshd"
-INITSCRIPT_PACKAGES = "${PN}-sshd"
-INITSCRIPT_NAME_${PN}-sshd = "sshd"
-INITSCRIPT_PARAMS_${PN}-sshd = "defaults 9"
+USERADD_PACKAGES = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', '${PN}-sshd', '', d)} \
+"
-SYSTEMD_PACKAGES = "${PN}-sshd"
-SYSTEMD_SERVICE_${PN}-sshd = "sshd.socket"
+USERADD_PARAM_${PN}-sshd = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', '--system --no-create-home --home-dir /var/run/sshd --shell /bin/false --user-group sshd', '', d)} \
+"
+
+INITSCRIPT_PACKAGES = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', '${PN}-sshd', '', d)} \
+"
+
+INITSCRIPT_NAME_${PN}-sshd = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', 'sshd', '', d)} \
+"
+
+INITSCRIPT_PARAMS_${PN}-sshd = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', 'defaults 9', '', d)} \
+"
+
+SYSTEMD_PACKAGES = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', '${PN}-sshd', '', d)} \
+"
+
+SYSTEMD_SERVICE_${PN}-sshd = "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', 'sshd.socket', '', d)} \
+"
+#USERADD_PACKAGES = "${PN}-sshd"
+#USERADD_PARAM_${PN}-sshd = "--system --no-create-home --home-dir /var/run/sshd --shell /bin/false --user-group sshd"
+#INITSCRIPT_PACKAGES = "${PN}-sshd"
+#INITSCRIPT_NAME_${PN}-sshd = "sshd"
+#INITSCRIPT_PARAMS_${PN}-sshd = "defaults 9"
+#
+#SYSTEMD_PACKAGES = "${PN}-sshd"
+#SYSTEMD_SERVICE_${PN}-sshd = "sshd.socket"
inherit autotools-brokensep ptest
@@ -144,7 +171,13 @@
FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
FILES_${PN}-keygen = "${bindir}/ssh-keygen"
-RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
+#RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
+RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-keygen"
+
+RDEPENDS_${PN} += "\
+ ${@bb.utils.contains('MOBILETEK_OPENSSH_CFG', 'PLATFORM', ' ${PN}-sshd', '', d)} \
+"
+
RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
diff --git a/meta/poky/meta/recipes-core/systemd/systemd/0027-lynq_change_timesyncd_to_not_auto_active.patch b/meta/poky/meta/recipes-core/systemd/systemd/0027-lynq_change_timesyncd_to_not_auto_active.patch
new file mode 100755
index 0000000..b943843
--- /dev/null
+++ b/meta/poky/meta/recipes-core/systemd/systemd/0027-lynq_change_timesyncd_to_not_auto_active.patch
@@ -0,0 +1,14 @@
+---
+ units/systemd-timesyncd.service | 1 -------------------------------------
+ 1 file changed, 1 deletions(-)
+
+diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in
+--- a/units/systemd-timesyncd.service.in
++++ b/units/systemd-timesyncd.service.in
+@@ -45,5 +45,4 @@
+ StateDirectory=systemd/timesync
+
+ [Install]
+-WantedBy=sysinit.target
+ Alias=dbus-org.freedesktop.timesync1.service
+ --
diff --git a/meta/poky/meta/recipes-core/systemd/systemd_239.bb b/meta/poky/meta/recipes-core/systemd/systemd_239.bb
old mode 100644
new mode 100755
index 7fbd64c..9185694
--- a/meta/poky/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/poky/meta/recipes-core/systemd/systemd_239.bb
@@ -45,6 +45,9 @@
file://sd-bus-if-we-receive-an-invalid-dbus-message-ignore-.patch \
"
+SRC_URI += "\
+ ${@bb.utils.contains('MOBILETEK_SYSTEMD_CFG', 'GSW', ' file://0027-lynq_change_timesyncd_to_not_auto_active.patch', '', d)} \
+"
# patches made for musl are only applied on TCLIBC is musl
SRC_URI += "${SRC_URI_MUSL}"
SRC_URI_MUSL = "file://0001-Use-getenv-when-secure-versions-are-not-available.patch \
@@ -303,6 +306,9 @@
# duplicate udevadm for postinst script
install -d ${D}${libexecdir}
ln ${D}${base_bindir}/udevadm ${D}${libexecdir}/${MLPREFIX}udevadm
+ if [ "${MOBILETEK_SYSTEMD_CFG}" = "GSW" ]; then
+ rm -rf ${D}/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service
+ fi
}
diff --git a/meta/poky/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.4.bb b/meta/poky/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.4.bb
old mode 100644
new mode 100755
index 8306605..494c728
--- a/meta/poky/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.4.bb
+++ b/meta/poky/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.14.4.bb
@@ -77,3 +77,11 @@
"
FILES_${PN}-equalizer += "${datadir}/gstreamer-1.0/presets/*.prs"
+
+#Typethree add 2022/9/20 for vlan start
+do_compile_prepend() {
+ if [ "${MOBILETEK_GSTREAMER_CFG}" = "GSW" ]; then
+ export SO_BINDTODEVICE=1
+ fi
+}
+#Typethree add 2022/9/20 for vlan end
\ No newline at end of file
diff --git a/src/bsp/lk/platform/mt2735/drivers/nandx/core/nand/device_slc.c b/src/bsp/lk/platform/mt2735/drivers/nandx/core/nand/device_slc.c
old mode 100644
new mode 100755
index b663257..ecfa847
--- a/src/bsp/lk/platform/mt2735/drivers/nandx/core/nand/device_slc.c
+++ b/src/bsp/lk/platform/mt2735/drivers/nandx/core/nand/device_slc.c
@@ -303,7 +303,7 @@
&slc_endurance, &slc_array_timing),
SLC_DRIVE_STRENGTH(0x80, 0x00, 0x01, 0x02, 0x03),
&onfi_extend_cmds,
- CHIP_TIMING_MODE3,
+ CHIP_TIMING_MODE2, //jb.qi change for ubi problem on 20221129
&timing_mode[0],
sdr_timing_micron_slc //MT29GZ6A6BPIET-046AAT.112
//zhengzhou for "MT29F8G08ADBFA"
diff --git a/src/bsp/lk/platform/mt2735/drivers/nandx/core/nfi/nfi_base.c b/src/bsp/lk/platform/mt2735/drivers/nandx/core/nfi/nfi_base.c
old mode 100644
new mode 100755
index 5511d3d..cf7f19d
--- a/src/bsp/lk/platform/mt2735/drivers/nandx/core/nfi/nfi_base.c
+++ b/src/bsp/lk/platform/mt2735/drivers/nandx/core/nfi/nfi_base.c
@@ -1418,6 +1418,7 @@
void *regs = nb->res.nfi_regs;
u32 tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt, tstrobe = 0;
u32 rate, val;
+ u16 thold; //jb.qi change for ubi problem on 20221129
int ret;
ret = wait_flash_macro_idle(regs);
@@ -1425,14 +1426,14 @@
return ret;
/* turn clock rate into KHZ */
- rate = nb->res.clock_1x / 1000;
+ rate = div_down(nb->res.clock_1x, 1000); //jb.qi change for ubi problem on 20221129
tpoecs = max_t(u32, sdr->tALH, sdr->tCLH);
tpoecs = div_up(tpoecs * rate, 1000000);
tpoecs &= 0xf;
tprecs = max_t(u32, sdr->tCLS, sdr->tALS);
- tprecs = div_up(tprecs * rate, 1000000);
+ tprecs = div_up(tprecs * rate, 1000000) + 1; //jb.qi change for ubi problem on 20221129
tprecs &= 0x3f;
/* tc2r is in unit of 2T */
@@ -1448,16 +1449,32 @@
twh = div_up(twh * rate, 1000000) - 1;
twh &= 0xf;
- twst = div_up(sdr->tWP * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 start*/
+ twst = 0;
+ thold = div_down((twh + 1) * 1000000, rate);
+ if (thold < sdr->tWC)
+ twst = sdr->tWC - thold;
+ twst = max_t(u32, sdr->tWP, twst);
+ twst = div_up(twst * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 end*/
twst &= 0xf;
- trlt = div_up(sdr->tRP * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 start*/
+ trlt = 0;
+ if (thold < sdr->tRC)
+ trlt = sdr->tRC - thold;
+ trlt = max_t(u32, sdr->tRP, trlt);
+ trlt = div_up(trlt * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 end*/
trlt &= 0xf;
+ tstrobe = 0; //jb.qi change for ubi problem on 20221129
/* If tREA is bigger than tRP, setup strobe sel here */
- if ((trlt + 1) * 1000000 / rate < sdr->tREA) {
- tstrobe = sdr->tREA - (trlt + 1) * 1000000 / rate;
- tstrobe = div_up(tstrobe * rate, 1000000);
+ /*jb.qi change for ubi problem on 20221129 start*/
+ if (div_down((trlt + 1) * 1000000, rate) < sdr->tREA) {
+ tstrobe = div_up(sdr->tREA * rate, 1000000);
+ tstrobe -= trlt + 1;
+ /*jb.qi change for ubi problem on 20221129 end*/
val = readl(regs + NFI_DEBUG_CON1);
val &= ~STROBE_MASK;
val |= tstrobe << STROBE_SHIFT;
@@ -1478,7 +1495,7 @@
* 03:00: trlt, read wait states
*/
val = ACCTIMING(tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt);
- pr_info("acctiming: 0x%x, tstrobe:%d\n", val, tstrobe);
+ pr_debug("NAND acctiming: 0x%x, strobe_sel:0x%x\n", val, tstrobe); //jb.qi change for ubi problem on 20221129
writel(val, regs + NFI_ACCCON);
/* set NAND type */
diff --git a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand/device_slc.c b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand/device_slc.c
old mode 100644
new mode 100755
index 175e6cd..0963660
--- a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand/device_slc.c
+++ b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand/device_slc.c
@@ -297,7 +297,7 @@
&slc_endurance, &slc_array_timing),
SLC_DRIVE_STRENGTH(0x80, 0x00, 0x01, 0x02, 0x03),
&onfi_extend_cmds,
- CHIP_TIMING_MODE3,
+ CHIP_TIMING_MODE2, //jb.qi change for ubi problem on 20221129
&timing_mode[0],
sdr_timing_micron_slc //zhengzhou for MT29GZ6A6BPIET-046AAT.112
},
diff --git a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.c b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.c
old mode 100644
new mode 100755
index 702da05..81f8755
--- a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.c
+++ b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.c
@@ -63,10 +63,6 @@
}
nand->performance->read_data_time = (int)time_cons;
#endif
- /*jb.qi change for ubi problem on 20221026 start*/
- if (ops[i].status < 0)
- pr_err("%s, row:0x%x, status: %d\n", __func__, row, ops[i].status);
- /*jb.qi change for ubi problem on 20221026 end*/
ret_max = max_t(int, ret_max, ops[i].status);
ret_min = min_t(int, ret_min, ops[i].status);
#if NANDX_PAGE_PERFORMANCE_TRACE
@@ -102,8 +98,6 @@
row = ops[i].row;
col = ops[i].col;
- pr_err("%s, row:0x%x\n", __func__, row);//jb.qi change for ubi problem on 20221026 start
-
nand->addressing(nand, &row, &col);
ops[i].status = nand->write_enable(nand);
@@ -166,6 +160,107 @@
return ret;
}
+/*jb.qi change for ubi problem on 20221129 start*/
+static inline void nand_bit_invert(u8 *buf, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ buf[i] = ~buf[i];
+}
+
+/**
+ * This function is called before erasing nand block, it wipes out EC
+ * and VID part nand page(s) in order to invalidate them and prevent the
+ * failures due to power loss during nand block erase operation.
+ * Since ec and vid info locate in separate nand page in non-subpage config
+ * proj, wipe out first two pages in non-subpage config project.
+ */
+static void nand_chip_erase_prepare(struct nand_chip *chip,
+ int row, int col)
+{
+ int nfi_ecc_en, nfi_ecc_en_old, ret, i;
+ int nfi_bbm_swap, nfi_bbm_swap_old;
+ int page_sectors = div_down(chip->page_size, chip->sector_size);
+ int sector_padded_size = chip->sector_size + chip->sector_spare_size;
+ int page_padded_size = page_sectors * sector_padded_size;
+ int count = 2;
+
+ struct nand_ops ops = {
+ .col = col,
+ .len = page_padded_size,
+ .data = chip->raw_buf,
+ .oob = NULL,
+ };
+
+ ret = nandx_ioctl(NFI_CTRL_ECC_GET_ECC_EN, &nfi_ecc_en_old);
+ if (ret) {
+ pr_err("%s:get ecc info fail at row %d, ret:%d\n",
+ __func__, row, ret);
+ return;
+ }
+
+ ret = nandx_ioctl(NFI_CTRL_BAD_MARK_SWAP_GET_SWAP_EN, &nfi_bbm_swap_old);
+ if (ret) {
+ pr_err("%s:get BBM swap status fail at row %d, ret:%d\n",
+ __func__, row, ret);
+ return;
+ }
+
+ /* To invert nand data, raw_read and raw_write operation are needed.
+ * Disable NFI ECC
+ */
+ nfi_ecc_en = 0;
+ ret = nandx_ioctl(NFI_CTRL_ECC, &nfi_ecc_en);
+ if (ret) {
+ pr_err("%s:disable ecc fail at row %d, ret:%d\n",
+ __func__, row, ret);
+ return;
+ }
+
+ nfi_bbm_swap = 0;
+ ret = nandx_ioctl(NFI_CTRL_BAD_MARK_SWAP, &nfi_bbm_swap);
+ if (ret) {
+ pr_err("%s:disable BBM swap at row %d, ret:%d\n",
+ __func__, row, ret);
+ goto restore_ecc;
+ }
+
+ for (i = 0; i < count; i++) {
+ ops.row = row + i;
+
+ memset(ops.data, 0xff, page_padded_size);
+ ret = chip->read_page(chip, &ops, 1);
+ if (ret < 0) {
+ pr_err("%s:raw read fail at row %d, ret:%d\n",
+ __func__, ops.row, ret);
+ break;
+ }
+
+ /* To avoid further 0 program causing difficulty to nand block
+ * erase operation, invert the whole nand page.
+ */
+ nand_bit_invert(ops.data, page_padded_size);
+
+ /* Ensure that nand block bad mark flag is not destroyed. */
+ *((u8 *)ops.data + chip->page_size) = 0xff;
+
+ /* Raw_write the inverted page data back to nand. */
+ ret = chip->write_page(chip, &ops, 1);
+ if (ret < 0) {
+ pr_err("%s:raw write fail at row %d, ret:%d\n",
+ __func__, ops.row, ret);
+ break;
+ }
+ }
+
+ nandx_ioctl(NFI_CTRL_BAD_MARK_SWAP, &nfi_bbm_swap_old);
+ /* Enable NFI ECC if need */
+restore_ecc:
+ nandx_ioctl(NFI_CTRL_ECC, &nfi_ecc_en_old);
+}
+/*jb.qi change for ubi problem on 20221129 end*/
+
static int nand_chip_erase_block(struct nand_chip *chip,
struct nand_ops *ops,
int count)
@@ -181,8 +276,12 @@
nand->addressing(nand, &row, &col);
- pr_err("%s, row:0x%x\n", __func__, row);//jb.qi change for ubi problem on 20221026 start
-
+ /*jb.qi change for ubi problem on 20221129 start*/
+ /* void type to avoid mis-judging this block as bad in ubi,
+ * nand block erase operation can continue
+ */
+ nand_chip_erase_prepare(chip, row, col);
+ /*jb.qi change for ubi problem on 20221129 end*/
ops[i].status = nand->write_enable(nand);
if (ops[i].status) {
pr_debug("Write Protect at %x!\n", row);
@@ -298,6 +397,11 @@
if (!nand)
goto nand_err;
+ chip->raw_buf = (u8 *)mem_alloc(1,
+ nand->dev->page_size + nand->dev->spare_size);
+ if (!chip->raw_buf)
+ goto nand_err;
+
chip->nand = (void *)nand;
chip->plane_num = nand->dev->plane_num;
chip->block_num = nand_total_blocks(nand->dev);
@@ -331,5 +435,6 @@
nand_spi_exit(chip->nand);
else
nand_exit(chip->nand);
+ mem_free(chip->raw_buf); //jb.qi change for ubi problem on 20221129
mem_free(chip);
}
diff --git a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.h b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.h
old mode 100644
new mode 100755
index 5295138..997fad0
--- a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.h
+++ b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nand_chip.h
@@ -75,7 +75,7 @@
u32 fdm_reg_size;
void *nand;
-
+ u8 *raw_buf; //jb.qi add for ubi problem on 20221129
int (*read_page)(struct nand_chip *chip, struct nand_ops *ops,
int count);
int (*write_page)(struct nand_chip *chip, struct nand_ops *ops,
diff --git a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nfi/nfi_base.c b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nfi/nfi_base.c
old mode 100644
new mode 100755
index 1f57869..e6528f5
--- a/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nfi/nfi_base.c
+++ b/src/kernel/linux/v4.19/drivers/mtd/nandx/core/nfi/nfi_base.c
@@ -558,7 +558,15 @@
case NFI_CTRL_BAD_MARK_SWAP:
nb->bad_mark_swap_en = *(bool *)args;
break;
+ /*jb.qi change for ubi problem on 20221129 start*/
+ case NFI_CTRL_BAD_MARK_SWAP_GET_SWAP_EN:
+ *(bool *)args = nb->bad_mark_swap_en;
+ break;
+ case NFI_CTRL_ECC_GET_ECC_EN:
+ *(bool *)args = nb->ecc_en;
+ break;
+ /*jb.qi change for ubi problem on 20221129 end*/
#ifdef NANDX_TEST_BUF_ALIGN
case NFI_ADDR_ALIGNMENT_EN:
if (*(u8 *)args)
@@ -1335,6 +1343,7 @@
void *regs = nb->res.nfi_regs;
u32 tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt, tstrobe;
u32 rate, val;
+ u16 thold; //jb.qi change for ubi problem on 20221129
int ret;
ret = wait_flash_macro_idle(regs);
@@ -1344,14 +1353,13 @@
}
/* turn clock rate into KHZ */
- rate = nb->res.clock_1x / 1000;
-
- tpoecs = max(sdr->tALH, sdr->tCLH);
+ rate = div_down(nb->res.clock_1x, 1000); //jb.qi change for ubi problem on 20221129
+ tpoecs = max(sdr->tALH, sdr->tCLH);
tpoecs = div_up(tpoecs * rate, 1000000);
tpoecs &= 0xf;
tprecs = max(sdr->tCLS, sdr->tALS);
- tprecs = div_up(tprecs * rate, 1000000);
+ tprecs = div_up(tprecs * rate, 1000000) + 1; //jb.qi change for ubi problem on 20221129
tprecs &= 0x3f;
/* tc2r is in unit of 2T */
@@ -1367,16 +1375,32 @@
twh = div_up(twh * rate, 1000000) - 1;
twh &= 0xf;
- twst = div_up(sdr->tWP * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 start*/
+ twst = 0;
+ thold = div_down((twh + 1) * 1000000, rate);
+ if (thold < sdr->tWC)
+ twst = sdr->tWC - thold;
+ twst = max((u32)sdr->tWP, twst);
+ twst = div_up(twst * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 end*/
twst &= 0xf;
- trlt = div_up(sdr->tRP * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 start*/
+ trlt = 0;
+ if (thold < sdr->tRC)
+ trlt = sdr->tRC - thold;
+ trlt = max((u32)sdr->tRP, trlt);
+ trlt = div_up(trlt * rate, 1000000) - 1;
+ /*jb.qi change for ubi problem on 20221129 end*/
trlt &= 0xf;
+ tstrobe = 0; //jb.qi change for ubi problem on 20221129
/* If tREA is bigger than tRP, setup strobe sel here */
- if ((trlt + 1) * 1000000 / rate < sdr->tREA) {
- tstrobe = sdr->tREA - (trlt + 1) * 1000000 / rate;
- tstrobe = div_up(tstrobe * rate, 1000000);
+ /*jb.qi change for ubi problem on 20221129 start*/
+ if (div_down((trlt + 1) * 1000000, rate) < sdr->tREA) {
+ tstrobe = div_up(sdr->tREA * rate, 1000000);
+ tstrobe -= trlt + 1;
+ /*jb.qi change for ubi problem on 20221129 end*/
val = readl(regs + NFI_DEBUG_CON1);
val &= ~STROBE_MASK;
val |= tstrobe << STROBE_SHIFT;
@@ -1397,7 +1421,7 @@
* 03:00: trlt, read wait states
*/
val = ACCTIMING(tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt);
- pr_debug("acctiming: 0x%x\n", val);
+ pr_debug("NAND acctiming: 0x%x, strobe_sel:0x%x\n", val, tstrobe); //jb.qi change for ubi problem on 20221129
writel(val, regs + NFI_ACCCON);
/* set NAND type */
diff --git a/src/kernel/linux/v4.19/drivers/mtd/nandx/include/internal/nandx_core.h b/src/kernel/linux/v4.19/drivers/mtd/nandx/include/internal/nandx_core.h
old mode 100644
new mode 100755
index 384ac5c..61d1288
--- a/src/kernel/linux/v4.19/drivers/mtd/nandx/include/internal/nandx_core.h
+++ b/src/kernel/linux/v4.19/drivers/mtd/nandx/include/internal/nandx_core.h
@@ -67,8 +67,11 @@
NFI_CTRL_ECC_DECODE_MODE,
NFI_CTRL_ECC_ERRNUM0,
NFI_CTRL_ECC_GET_STATUS, /*20*/
+ NFI_CTRL_ECC_GET_ECC_EN, //jb.qi change for ubi problem on 20221129
+
NFI_CTRL_BAD_MARK_SWAP,
+ NFI_CTRL_BAD_MARK_SWAP_GET_SWAP_EN, //jb.qi change for ubi problem on 20221129
NFI_CTRL_IOCON,
SNFI_CTRL_OP_MODE,
diff --git a/src/kernel/linux/v4.19/fs/ubifs/lpt.c b/src/kernel/linux/v4.19/fs/ubifs/lpt.c
index 22ba82e..3139337 100644
--- a/src/kernel/linux/v4.19/fs/ubifs/lpt.c
+++ b/src/kernel/linux/v4.19/fs/ubifs/lpt.c
@@ -1334,11 +1334,6 @@
buf = vmalloc(c->ltab_sz);
if (!buf)
return -ENOMEM;
- /*jb.qi change for ubi problem on 20221026 start*/
- /* check the whole LEB */
- ubifs_err(c, "check the LEB of ltab!\n");
- ubifs_leb_read(c, c->ltab_lnum, c->sbuf, 0, c->leb_size, 1);
- /*jb.qi change for ubi problem on 20221026 end*/
err = ubifs_leb_read(c, c->ltab_lnum, buf, c->ltab_offs, c->ltab_sz, 1);
if (err)
goto out;
diff --git a/src/kernel/linux/v4.19/fs/ubifs/recovery.c b/src/kernel/linux/v4.19/fs/ubifs/recovery.c
index 36107ee..abf4597 100644
--- a/src/kernel/linux/v4.19/fs/ubifs/recovery.c
+++ b/src/kernel/linux/v4.19/fs/ubifs/recovery.c
@@ -923,7 +923,7 @@
static int recover_head(struct ubifs_info *c, int lnum, int offs, void *sbuf)
{
int len = c->max_write_size, err;
-
+ bool forceclean = true; //jb.qi add for ubi problem on 20221129
if (offs + len > c->leb_size)
len = c->leb_size - offs;
@@ -932,8 +932,8 @@
/* Read at the head location and check it is empty flash */
err = ubifs_leb_read(c, lnum, sbuf, offs, len, 1);
- if (err || !is_empty(sbuf, len)) {
- ubifs_err(c, "cleaning head at %d:%d", lnum, offs); //jb.qi change for ubi problem on 20221026
+ if (err || !is_empty(sbuf, len) || forceclean) { //jb.qi add for ubi problem on 20221129
+ dbg_rcvry("cleaning head at %d:%d", lnum, offs);
if (offs == 0)
return ubifs_leb_unmap(c, lnum);
err = ubifs_leb_read(c, lnum, sbuf, 0, offs, 1);
@@ -968,12 +968,12 @@
ubifs_assert(c, !c->ro_mount || c->remounting_rw);
- ubifs_err(c, "checking index head at %d:%d", c->ihead_lnum, c->ihead_offs);//jb.qi change for ubi problem on 20221026
+ dbg_rcvry("checking index head at %d:%d", c->ihead_lnum, c->ihead_offs);
err = recover_head(c, c->ihead_lnum, c->ihead_offs, sbuf);
if (err)
return err;
- ubifs_err(c, "checking LPT head at %d:%d", c->nhead_lnum, c->nhead_offs);//jb.qi change for ubi problem on 20221026
+ dbg_rcvry("checking LPT head at %d:%d", c->nhead_lnum, c->nhead_offs);
return recover_head(c, c->nhead_lnum, c->nhead_offs, sbuf);
}