swuforward: drop support for V1 Website
diff mbox series

Message ID 20190716150103.32399-1-sbabic@denx.de
State Accepted
Headers show
Series
  • swuforward: drop support for V1 Website
Related show

Commit Message

Stefano Babic July 16, 2019, 3:01 p.m. UTC
Old version of Website is not suppoerted anymore, drop the test to check
the Website on the remote.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 handlers/swuforward_handler.c | 116 ----------------------------------
 handlers/swuforward_handler.h |   8 ---
 2 files changed, 124 deletions(-)

Comments

oktetti@gmail.com Sept. 13, 2019, 7:42 a.m. UTC | #1
I just noticed this, sorry for being so late...

Was this decision discussed at all? Could not find any discussion on this 
group.

Assume a situation where a "module" is running SWUpdate in V1 mode, 
intended to be updated by the "master" device via the swuforward handler. 
The master in this scenario would be running the latest SWUpdate, no longer 
supporting V1, meaning the "module" is now unreachable for software 
upgrades.

How would you solve the situation? Or are we forever stuck on SWUpdate 
release 2018.11?

Br, Sami


On Tuesday, July 16, 2019 at 6:01:11 PM UTC+3, Stefano Babic wrote:

> Old version of Website is not suppoerted anymore, drop the test to check 
> the Website on the remote. 
>
> Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>> 
> --- 
>  handlers/swuforward_handler.c | 116 ---------------------------------- 
>  handlers/swuforward_handler.h |   8 --- 
>  2 files changed, 124 deletions(-) 
>
> diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c 
> index bd8afc9..4ddaf35 100644 
> --- a/handlers/swuforward_handler.c 
> +++ b/handlers/swuforward_handler.c 
> @@ -217,96 +217,6 @@ curl_thread_exit: 
>          pthread_exit(NULL); 
>  } 
>   
> - 
> -static json_object *parse_reqstatus(json_object *reply, const char 
> **json_path) 
> -{ 
> -        json_object *json_data; 
> - 
> -        json_data = json_get_path_key(reply, json_path); 
> -        if (json_data == NULL) { 
> -                ERROR("Got malformed JSON: Could not find path"); 
> -                DEBUG("Got JSON: %s", 
> json_object_to_json_string(json_data)); 
> -        } 
> - 
> -        return json_data; 
> -} 
> - 
> -/* 
> - * Send a GET to retrieve all traces from the connected board 
> - */ 
> -static int get_answer_V1(struct curlconn *conn, RECOVERY_STATUS *result, 
> bool ignore) 
> -{ 
> -        channel_data_t channel_cfg = { 
> -                .debug = false, 
> -                .retries = 0, 
> -                .retry_sleep = 0, 
> -                .usessl = false}; 
> -        channel_t *channel = channel_new(); 
> -        json_object *json_data; 
> -        int status; 
> - 
> -        conn->response = CHANNEL_EIO; 
> -        /* 
> -         * Open a curl channel, do not connect yet 
> -         */ 
> -        if (channel->open(channel, &channel_cfg) != CHANNEL_OK) { 
> -                return -EIO; 
> -        } 
> - 
> -        if (asprintf(&channel_cfg.url, "%s%s", 
> -                         conn->url, STATUS_URL_V1) < 0) { 
> -                ERROR("Out of memory."); 
> -                return -ENOMEM; 
> -        } 
> - 
> -        /* Retrieve last message */ 
> -        conn->response = channel->get(channel, (void *)&channel_cfg); 
> - 
> -        if (conn->response != CHANNEL_OK) { 
> -                status = -EIO; 
> -                goto cleanup; 
> -        } 
> - 
> -        /* Retrieve all fields */ 
> -        status = -EBADMSG; 
> -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply, 
> -                                        (const char *[]){"Status", 
> NULL}))) 
> -                goto cleanup; 
> -        status = json_object_get_int(json_data); 
> - 
> -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply, 
> -                                        (const char *[]){"Msg", NULL}))) 
> -                goto cleanup; 
> -        const char *msg = json_object_get_string(json_data); 
> - 
> -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply, 
> -                                        (const char *[]){"LastResult", 
> NULL}))) 
> -                goto cleanup; 
> -        int lastResult = json_object_get_int(json_data); 
> - 
> -        if (strlen(msg) > 0) 
> -                conn->gotMsg = (strlen(msg) > 0) ? true : false; 
> - 
> -        if (!ignore) { 
> -                if (strlen(msg)) { 
> -                        TRACE("Update to %s :  %s", conn->url, msg); 
> -                } 
> -                if (status == IDLE) { 
> -                        TRACE("Update to %s : %s", conn->url, 
> -                                (lastResult == SUCCESS) ? "SUCCESS !" : 
> "FAILURE"); 
> -                } 
> -        } 
> - 
> -        *result = lastResult; 
> - 
> -cleanup: 
> -        free(channel_cfg.url); 
> -        channel->close(channel); 
> -        free(channel); 
> - 
> -        return status; 
> -} 
> - 
>  static int retrieve_msgs(struct hnd_priv *priv) { 
>          struct curlconn *conn; 
>          int ret; 
> @@ -432,32 +342,6 @@ static int install_remote_swu(struct img_type *img, 
>                  conn->total_bytes = img->size; 
>                  conn->SWUpdateStatus = IDLE; 
>   
> -                /* 
> -                 * Try to connect to check Webserver Version 
> -                 * If there is an anwer, but with HTTP=404 
> -                 * it is V2 
> -                 * Just V2 is supported (TODO: support older versions, 
> too ?) 
> -                 */ 
> - 
> -                ret = get_answer_V1(conn, &conn->SWUpdateStatus, true); 
> -                if (ret < 0 && (conn->response == CHANNEL_ENOTFOUND)) { 
> -                        conn->ver = SWUPDATE_WWW_V2; 
> -                } else if (!ret) { 
> -                        conn->ver = SWUPDATE_WWW_V1; 
> -                } else { 
> -                        ERROR("Remote SWUpdate not answering"); 
> -                        ret = FAILURE; 
> -                        goto handler_exit; 
> -                } 
> -                TRACE("Found remote server V%d", 
> -                        conn->ver == SWUPDATE_WWW_V2 ? SWUPDATE_WWW_V2 : 
> SWUPDATE_WWW_V1); 
> - 
> -                if (conn->ver == SWUPDATE_WWW_V1) { 
> -                        ERROR("FAULT: there is no support for older 
> website"); 
> -                        ret = FAILURE; 
> -                        goto handler_exit; 
> -                } 
> - 
>                  /* 
>                   * Create one FIFO for each connection to be thread safe 
>                   */ 
> diff --git a/handlers/swuforward_handler.h b/handlers/swuforward_handler.h 
> index f770ca0..865fabf 100644 
> --- a/handlers/swuforward_handler.h 
> +++ b/handlers/swuforward_handler.h 
> @@ -19,9 +19,7 @@ 
>   */ 
>  #define CUSTOM_HEADER "X_FILENAME: " 
>  #define MAX_WAIT_MS        3000 
> -#define POST_URL_V1        "/handle_post_request" 
>  #define POST_URL_V2        "/upload" 
> -#define STATUS_URL_V1        "/getstatus.json" 
>   
>  /* 
>   * The handler checks if a remote update was successful 
> @@ -33,11 +31,6 @@ 
>  #define TIMEOUT_GET_ANSWER_SEC                900        /* 15 minutes */ 
>  #define POLLING_TIME_REQ_STATUS                50        /* in mSec */ 
>   
> -typedef enum { 
> -        SWUPDATE_WWW_V1 = 1, 
> -        SWUPDATE_WWW_V2 = 2, 
> -} SWUPDATE_WEB_VER; 
> - 
>  typedef enum { 
>          WS_UNKNOWN, 
>          WS_ESTABLISHED, 
> @@ -59,7 +52,6 @@ struct curlconn { 
>          size_t total_bytes;        /* size of SWU image */ 
>          int fifo[2];                /* Pipe for IPC */ 
>          char *url;                /* URL for forwarding */ 
> -        SWUPDATE_WEB_VER ver;        /* version of remote Webserver (V1 
> or V2) */ 
>          bool gotMsg;                /* set if the remote board has sent a 
> new msg */ 
>          RECOVERY_STATUS SWUpdateStatus;        /* final status of update 
> */ 
>          channel_op_res_t response; 
> -- 
> 2.17.1 
>
>
Stefano Babic Sept. 13, 2019, 8:12 a.m. UTC | #2
Hi Sami,

On 13/09/19 09:42, oktetti@gmail.com wrote:
> I just noticed this, sorry for being so late...
> 
> Was this decision discussed at all?

Nobody complained - this patch is a follow up of this series:

https://groups.google.com/forum/#!searchin/swupdate/swuforward$3A$20rework$20to$20use$20new$20Website%7Csort:date/swupdate/YIpxdN-G0cs/jwIG4i8lDQAJ

This series (posted in June) has already dropped V1 support - the patch
here just drop the check about the version, nothing more.

It was already posted that the swuforwarder was broken with new libcurl
releases:

https://groups.google.com/forum/#!searchin/swupdate/swuforward%7Csort:date/swupdate/B6IvWMkQLnY/1CYJC7HLBAAJ


> Could not find any discussion on
> this group.

See above - there was several threads about issues with swuforwarder in
new releases. The legacy website itself was already dropped from the
internal webserver (just "-V1" remained to let it compatible with
swuforwarder) and the logical consequence was to rework the swuforwarder
to be aligned with actual development.

> 
> Assume a situation where a "module" is running SWUpdate in V1 mode,
> intended to be updated by the "master" device via the swuforward
> handler.

The good question is why the master is singularly updated instead of
running a system update on all modules, including the master. This
guarantees that all modules will run the new SWUpdate (if successful) or
the old one (if unsuccessful), but the system remains compatible.

I agree that this a limitation, but because nobody complained, the
limitation of dropping the single board update vs a system update was
accepted. This is also how I arranged the change in my projects (just
system update, no single update until target gets new SWUpdate).

> The master in this scenario would be running the latest
> SWUpdate, no longer supporting V1, meaning the "module" is now
> unreachable for software upgrades.

I know, see above.

> 
> How would you solve the situation?

The old mechanism could be implemented again in the actual SWUpdate.
This is possible and I could do if a customer asks it, but my customers
have already upgraded and they are running newer SWUpdate.

> Or are we forever stuck on SWUpdate
> release 2018.11?

This is quite dangerous - not only on SWUpdate, but you have to stick at
least on older libcurl (< 7.6.1). Newer libcurl introduces an
asynchronous mechanism that generates a race in the swuforwarder
handler. The slaves modules receive a corrupted image and an update is
not successful.

Best regards,
Stefano Babic

> 
> Br, Sami
> 
> 
> On Tuesday, July 16, 2019 at 6:01:11 PM UTC+3, Stefano Babic wrote:
> 
>     Old version of Website is not suppoerted anymore, drop the test to
>     check
>     the Website on the remote.
> 
>     Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>>
>     ---
>      handlers/swuforward_handler.c | 116 ----------------------------------
>      handlers/swuforward_handler.h |   8 ---
>      2 files changed, 124 deletions(-)
> 
>     diff --git a/handlers/swuforward_handler.c
>     b/handlers/swuforward_handler.c
>     index bd8afc9..4ddaf35 100644
>     --- a/handlers/swuforward_handler.c
>     +++ b/handlers/swuforward_handler.c
>     @@ -217,96 +217,6 @@ curl_thread_exit:
>              pthread_exit(NULL);
>      }
>      
>     -
>     -static json_object *parse_reqstatus(json_object *reply, const char
>     **json_path)
>     -{
>     -        json_object *json_data;
>     -
>     -        json_data = json_get_path_key(reply, json_path);
>     -        if (json_data == NULL) {
>     -                ERROR("Got malformed JSON: Could not find path");
>     -                DEBUG("Got JSON: %s",
>     json_object_to_json_string(json_data));
>     -        }
>     -
>     -        return json_data;
>     -}
>     -
>     -/*
>     - * Send a GET to retrieve all traces from the connected board
>     - */
>     -static int get_answer_V1(struct curlconn *conn, RECOVERY_STATUS
>     *result, bool ignore)
>     -{
>     -        channel_data_t channel_cfg = {
>     -                .debug = false,
>     -                .retries = 0,
>     -                .retry_sleep = 0,
>     -                .usessl = false};
>     -        channel_t *channel = channel_new();
>     -        json_object *json_data;
>     -        int status;
>     -
>     -        conn->response = CHANNEL_EIO;
>     -        /*
>     -         * Open a curl channel, do not connect yet
>     -         */
>     -        if (channel->open(channel, &channel_cfg) != CHANNEL_OK) {
>     -                return -EIO;
>     -        }
>     -
>     -        if (asprintf(&channel_cfg.url, "%s%s",
>     -                         conn->url, STATUS_URL_V1) < 0) {
>     -                ERROR("Out of memory.");
>     -                return -ENOMEM;
>     -        }
>     -
>     -        /* Retrieve last message */
>     -        conn->response = channel->get(channel, (void *)&channel_cfg);
>     -
>     -        if (conn->response != CHANNEL_OK) {
>     -                status = -EIO;
>     -                goto cleanup;
>     -        }
>     -
>     -        /* Retrieve all fields */
>     -        status = -EBADMSG;
>     -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply,
>     -                                        (const char *[]){"Status",
>     NULL})))
>     -                goto cleanup;
>     -        status = json_object_get_int(json_data);
>     -
>     -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply,
>     -                                        (const char *[]){"Msg",
>     NULL})))
>     -                goto cleanup;
>     -        const char *msg = json_object_get_string(json_data);
>     -
>     -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply,
>     -                                        (const char
>     *[]){"LastResult", NULL})))
>     -                goto cleanup;
>     -        int lastResult = json_object_get_int(json_data);
>     -
>     -        if (strlen(msg) > 0)
>     -                conn->gotMsg = (strlen(msg) > 0) ? true : false;
>     -
>     -        if (!ignore) {
>     -                if (strlen(msg)) {
>     -                        TRACE("Update to %s :  %s", conn->url, msg);
>     -                }
>     -                if (status == IDLE) {
>     -                        TRACE("Update to %s : %s", conn->url,
>     -                                (lastResult == SUCCESS) ? "SUCCESS
>     !" : "FAILURE");
>     -                }
>     -        }
>     -
>     -        *result = lastResult;
>     -
>     -cleanup:
>     -        free(channel_cfg.url);
>     -        channel->close(channel);
>     -        free(channel);
>     -
>     -        return status;
>     -}
>     -
>      static int retrieve_msgs(struct hnd_priv *priv) {
>              struct curlconn *conn;
>              int ret;
>     @@ -432,32 +342,6 @@ static int install_remote_swu(struct img_type
>     *img,
>                      conn->total_bytes = img->size;
>                      conn->SWUpdateStatus = IDLE;
>      
>     -                /*
>     -                 * Try to connect to check Webserver Version
>     -                 * If there is an anwer, but with HTTP=404
>     -                 * it is V2
>     -                 * Just V2 is supported (TODO: support older
>     versions, too ?)
>     -                 */
>     -
>     -                ret = get_answer_V1(conn, &conn->SWUpdateStatus,
>     true);
>     -                if (ret < 0 && (conn->response ==
>     CHANNEL_ENOTFOUND)) {
>     -                        conn->ver = SWUPDATE_WWW_V2;
>     -                } else if (!ret) {
>     -                        conn->ver = SWUPDATE_WWW_V1;
>     -                } else {
>     -                        ERROR("Remote SWUpdate not answering");
>     -                        ret = FAILURE;
>     -                        goto handler_exit;
>     -                }
>     -                TRACE("Found remote server V%d",
>     -                        conn->ver == SWUPDATE_WWW_V2 ?
>     SWUPDATE_WWW_V2 : SWUPDATE_WWW_V1);
>     -
>     -                if (conn->ver == SWUPDATE_WWW_V1) {
>     -                        ERROR("FAULT: there is no support for older
>     website");
>     -                        ret = FAILURE;
>     -                        goto handler_exit;
>     -                }
>     -
>                      /*
>                       * Create one FIFO for each connection to be thread
>     safe
>                       */
>     diff --git a/handlers/swuforward_handler.h
>     b/handlers/swuforward_handler.h
>     index f770ca0..865fabf 100644
>     --- a/handlers/swuforward_handler.h
>     +++ b/handlers/swuforward_handler.h
>     @@ -19,9 +19,7 @@
>       */
>      #define CUSTOM_HEADER "X_FILENAME: "
>      #define MAX_WAIT_MS        3000
>     -#define POST_URL_V1        "/handle_post_request"
>      #define POST_URL_V2        "/upload"
>     -#define STATUS_URL_V1        "/getstatus.json"
>      
>      /*
>       * The handler checks if a remote update was successful
>     @@ -33,11 +31,6 @@
>      #define TIMEOUT_GET_ANSWER_SEC                900        /* 15
>     minutes */
>      #define POLLING_TIME_REQ_STATUS                50        /* in mSec */
>      
>     -typedef enum {
>     -        SWUPDATE_WWW_V1 = 1,
>     -        SWUPDATE_WWW_V2 = 2,
>     -} SWUPDATE_WEB_VER;
>     -
>      typedef enum {
>              WS_UNKNOWN,
>              WS_ESTABLISHED,
>     @@ -59,7 +52,6 @@ struct curlconn {
>              size_t total_bytes;        /* size of SWU image */
>              int fifo[2];                /* Pipe for IPC */
>              char *url;                /* URL for forwarding */
>     -        SWUPDATE_WEB_VER ver;        /* version of remote Webserver
>     (V1 or V2) */
>              bool gotMsg;                /* set if the remote board has
>     sent a new msg */
>              RECOVERY_STATUS SWUpdateStatus;        /* final status of
>     update */
>              channel_op_res_t response;
>     -- 
>     2.17.1
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+unsubscribe@googlegroups.com
> <mailto:swupdate+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/7f1c1138-939e-49ce-80a5-414da17fde86%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/7f1c1138-939e-49ce-80a5-414da17fde86%40googlegroups.com?utm_medium=email&utm_source=footer>.
oktetti@gmail.com Sept. 13, 2019, 9:39 a.m. UTC | #3
Hi Stefano,

My bad for not finding the posts you mentioned. The issue with libcurl sure 
explains why V1 was dropped IMHO so quickly (not having swuforward 
supporting both V1 and V2 for a release or two).

Thanks for explaining the situation with swuforward & V1.

Br, Sami

On Friday, September 13, 2019 at 11:12:10 AM UTC+3, Stefano Babic wrote:

> Hi Sami, 
>
> On 13/09/19 09:42, okt...@gmail.com <javascript:> wrote: 
> > I just noticed this, sorry for being so late... 
> > 
> > Was this decision discussed at all? 
>
> Nobody complained - this patch is a follow up of this series: 
>
>
> https://groups.google.com/forum/#!searchin/swupdate/swuforward$3A$20rework$20to$20use$20new$20Website%7Csort:date/swupdate/YIpxdN-G0cs/jwIG4i8lDQAJ 
>
> This series (posted in June) has already dropped V1 support - the patch 
> here just drop the check about the version, nothing more. 
>
> It was already posted that the swuforwarder was broken with new libcurl 
> releases: 
>
>
> https://groups.google.com/forum/#!searchin/swupdate/swuforward%7Csort:date/swupdate/B6IvWMkQLnY/1CYJC7HLBAAJ 
>
>
> > Could not find any discussion on 
> > this group. 
>
> See above - there was several threads about issues with swuforwarder in 
> new releases. The legacy website itself was already dropped from the 
> internal webserver (just "-V1" remained to let it compatible with 
> swuforwarder) and the logical consequence was to rework the swuforwarder 
> to be aligned with actual development. 
>
> > 
> > Assume a situation where a "module" is running SWUpdate in V1 mode, 
> > intended to be updated by the "master" device via the swuforward 
> > handler. 
>
> The good question is why the master is singularly updated instead of 
> running a system update on all modules, including the master. This 
> guarantees that all modules will run the new SWUpdate (if successful) or 
> the old one (if unsuccessful), but the system remains compatible. 
>
> I agree that this a limitation, but because nobody complained, the 
> limitation of dropping the single board update vs a system update was 
> accepted. This is also how I arranged the change in my projects (just 
> system update, no single update until target gets new SWUpdate). 
>
> > The master in this scenario would be running the latest 
> > SWUpdate, no longer supporting V1, meaning the "module" is now 
> > unreachable for software upgrades. 
>
> I know, see above. 
>
> > 
> > How would you solve the situation? 
>
> The old mechanism could be implemented again in the actual SWUpdate. 
> This is possible and I could do if a customer asks it, but my customers 
> have already upgraded and they are running newer SWUpdate. 
>
> > Or are we forever stuck on SWUpdate 
> > release 2018.11? 
>
> This is quite dangerous - not only on SWUpdate, but you have to stick at 
> least on older libcurl (< 7.6.1). Newer libcurl introduces an 
> asynchronous mechanism that generates a race in the swuforwarder 
> handler. The slaves modules receive a corrupted image and an update is 
> not successful. 
>
> Best regards, 
> Stefano Babic 
>
> > 
> > Br, Sami 
> > 
> > 
> > On Tuesday, July 16, 2019 at 6:01:11 PM UTC+3, Stefano Babic wrote: 
> > 
> >     Old version of Website is not suppoerted anymore, drop the test to 
> >     check 
> >     the Website on the remote. 
> > 
> >     Signed-off-by: Stefano Babic <sba...@denx.de <javascript:>> 
> >     --- 
> >      handlers/swuforward_handler.c | 116 
> ---------------------------------- 
> >      handlers/swuforward_handler.h |   8 --- 
> >      2 files changed, 124 deletions(-) 
> > 
> >     diff --git a/handlers/swuforward_handler.c 
> >     b/handlers/swuforward_handler.c 
> >     index bd8afc9..4ddaf35 100644 
> >     --- a/handlers/swuforward_handler.c 
> >     +++ b/handlers/swuforward_handler.c 
> >     @@ -217,96 +217,6 @@ curl_thread_exit: 
> >              pthread_exit(NULL); 
> >      } 
> >       
> >     - 
> >     -static json_object *parse_reqstatus(json_object *reply, const char 
> >     **json_path) 
> >     -{ 
> >     -        json_object *json_data; 
> >     - 
> >     -        json_data = json_get_path_key(reply, json_path); 
> >     -        if (json_data == NULL) { 
> >     -                ERROR("Got malformed JSON: Could not find path"); 
> >     -                DEBUG("Got JSON: %s", 
> >     json_object_to_json_string(json_data)); 
> >     -        } 
> >     - 
> >     -        return json_data; 
> >     -} 
> >     - 
> >     -/* 
> >     - * Send a GET to retrieve all traces from the connected board 
> >     - */ 
> >     -static int get_answer_V1(struct curlconn *conn, RECOVERY_STATUS 
> >     *result, bool ignore) 
> >     -{ 
> >     -        channel_data_t channel_cfg = { 
> >     -                .debug = false, 
> >     -                .retries = 0, 
> >     -                .retry_sleep = 0, 
> >     -                .usessl = false}; 
> >     -        channel_t *channel = channel_new(); 
> >     -        json_object *json_data; 
> >     -        int status; 
> >     - 
> >     -        conn->response = CHANNEL_EIO; 
> >     -        /* 
> >     -         * Open a curl channel, do not connect yet 
> >     -         */ 
> >     -        if (channel->open(channel, &channel_cfg) != CHANNEL_OK) { 
> >     -                return -EIO; 
> >     -        } 
> >     - 
> >     -        if (asprintf(&channel_cfg.url, "%s%s", 
> >     -                         conn->url, STATUS_URL_V1) < 0) { 
> >     -                ERROR("Out of memory."); 
> >     -                return -ENOMEM; 
> >     -        } 
> >     - 
> >     -        /* Retrieve last message */ 
> >     -        conn->response = channel->get(channel, (void 
> *)&channel_cfg); 
> >     - 
> >     -        if (conn->response != CHANNEL_OK) { 
> >     -                status = -EIO; 
> >     -                goto cleanup; 
> >     -        } 
> >     - 
> >     -        /* Retrieve all fields */ 
> >     -        status = -EBADMSG; 
> >     -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply, 
> >     -                                        (const char *[]){"Status", 
> >     NULL}))) 
> >     -                goto cleanup; 
> >     -        status = json_object_get_int(json_data); 
> >     - 
> >     -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply, 
> >     -                                        (const char *[]){"Msg", 
> >     NULL}))) 
> >     -                goto cleanup; 
> >     -        const char *msg = json_object_get_string(json_data); 
> >     - 
> >     -        if (!(json_data = parse_reqstatus(channel_cfg.json_reply, 
> >     -                                        (const char 
> >     *[]){"LastResult", NULL}))) 
> >     -                goto cleanup; 
> >     -        int lastResult = json_object_get_int(json_data); 
> >     - 
> >     -        if (strlen(msg) > 0) 
> >     -                conn->gotMsg = (strlen(msg) > 0) ? true : false; 
> >     - 
> >     -        if (!ignore) { 
> >     -                if (strlen(msg)) { 
> >     -                        TRACE("Update to %s :  %s", conn->url, 
> msg); 
> >     -                } 
> >     -                if (status == IDLE) { 
> >     -                        TRACE("Update to %s : %s", conn->url, 
> >     -                                (lastResult == SUCCESS) ? "SUCCESS 
> >     !" : "FAILURE"); 
> >     -                } 
> >     -        } 
> >     - 
> >     -        *result = lastResult; 
> >     - 
> >     -cleanup: 
> >     -        free(channel_cfg.url); 
> >     -        channel->close(channel); 
> >     -        free(channel); 
> >     - 
> >     -        return status; 
> >     -} 
> >     - 
> >      static int retrieve_msgs(struct hnd_priv *priv) { 
> >              struct curlconn *conn; 
> >              int ret; 
> >     @@ -432,32 +342,6 @@ static int install_remote_swu(struct img_type 
> >     *img, 
> >                      conn->total_bytes = img->size; 
> >                      conn->SWUpdateStatus = IDLE; 
> >       
> >     -                /* 
> >     -                 * Try to connect to check Webserver Version 
> >     -                 * If there is an anwer, but with HTTP=404 
> >     -                 * it is V2 
> >     -                 * Just V2 is supported (TODO: support older 
> >     versions, too ?) 
> >     -                 */ 
> >     - 
> >     -                ret = get_answer_V1(conn, &conn->SWUpdateStatus, 
> >     true); 
> >     -                if (ret < 0 && (conn->response == 
> >     CHANNEL_ENOTFOUND)) { 
> >     -                        conn->ver = SWUPDATE_WWW_V2; 
> >     -                } else if (!ret) { 
> >     -                        conn->ver = SWUPDATE_WWW_V1; 
> >     -                } else { 
> >     -                        ERROR("Remote SWUpdate not answering"); 
> >     -                        ret = FAILURE; 
> >     -                        goto handler_exit; 
> >     -                } 
> >     -                TRACE("Found remote server V%d", 
> >     -                        conn->ver == SWUPDATE_WWW_V2 ? 
> >     SWUPDATE_WWW_V2 : SWUPDATE_WWW_V1); 
> >     - 
> >     -                if (conn->ver == SWUPDATE_WWW_V1) { 
> >     -                        ERROR("FAULT: there is no support for older 
> >     website"); 
> >     -                        ret = FAILURE; 
> >     -                        goto handler_exit; 
> >     -                } 
> >     - 
> >                      /* 
> >                       * Create one FIFO for each connection to be thread 
> >     safe 
> >                       */ 
> >     diff --git a/handlers/swuforward_handler.h 
> >     b/handlers/swuforward_handler.h 
> >     index f770ca0..865fabf 100644 
> >     --- a/handlers/swuforward_handler.h 
> >     +++ b/handlers/swuforward_handler.h 
> >     @@ -19,9 +19,7 @@ 
> >       */ 
> >      #define CUSTOM_HEADER "X_FILENAME: " 
> >      #define MAX_WAIT_MS        3000 
> >     -#define POST_URL_V1        "/handle_post_request" 
> >      #define POST_URL_V2        "/upload" 
> >     -#define STATUS_URL_V1        "/getstatus.json" 
> >       
> >      /* 
> >       * The handler checks if a remote update was successful 
> >     @@ -33,11 +31,6 @@ 
> >      #define TIMEOUT_GET_ANSWER_SEC                900        /* 15 
> >     minutes */ 
> >      #define POLLING_TIME_REQ_STATUS                50        /* in mSec 
> */ 
> >       
> >     -typedef enum { 
> >     -        SWUPDATE_WWW_V1 = 1, 
> >     -        SWUPDATE_WWW_V2 = 2, 
> >     -} SWUPDATE_WEB_VER; 
> >     - 
> >      typedef enum { 
> >              WS_UNKNOWN, 
> >              WS_ESTABLISHED, 
> >     @@ -59,7 +52,6 @@ struct curlconn { 
> >              size_t total_bytes;        /* size of SWU image */ 
> >              int fifo[2];                /* Pipe for IPC */ 
> >              char *url;                /* URL for forwarding */ 
> >     -        SWUPDATE_WEB_VER ver;        /* version of remote Webserver 
> >     (V1 or V2) */ 
> >              bool gotMsg;                /* set if the remote board has 
> >     sent a new msg */ 
> >              RECOVERY_STATUS SWUpdateStatus;        /* final status of 
> >     update */ 
> >              channel_op_res_t response; 
> >     -- 
> >     2.17.1 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "swupdate" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to swup...@googlegroups.com <javascript:> 
> > <mailto:swup...@googlegroups.com <javascript:>>. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/swupdate/7f1c1138-939e-49ce-80a5-414da17fde86%40googlegroups.com 
> > <
> https://groups.google.com/d/msgid/swupdate/7f1c1138-939e-49ce-80a5-414da17fde86%40googlegroups.com?utm_medium=email&utm_source=footer>. 
>
>
>
> -- 
> ===================================================================== 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk 
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de 
> <javascript:> 
> ===================================================================== 
>

Patch
diff mbox series

diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c
index bd8afc9..4ddaf35 100644
--- a/handlers/swuforward_handler.c
+++ b/handlers/swuforward_handler.c
@@ -217,96 +217,6 @@  curl_thread_exit:
 	pthread_exit(NULL);
 }
 
-
-static json_object *parse_reqstatus(json_object *reply, const char **json_path)
-{
-	json_object *json_data;
-
-	json_data = json_get_path_key(reply, json_path);
-	if (json_data == NULL) {
-		ERROR("Got malformed JSON: Could not find path");
-		DEBUG("Got JSON: %s", json_object_to_json_string(json_data));
-	}
-
-	return json_data;
-}
-
-/*
- * Send a GET to retrieve all traces from the connected board
- */
-static int get_answer_V1(struct curlconn *conn, RECOVERY_STATUS *result, bool ignore)
-{
-	channel_data_t channel_cfg = {
-		.debug = false,
-		.retries = 0,
-		.retry_sleep = 0,
-		.usessl = false};
-	channel_t *channel = channel_new();
-	json_object *json_data;
-	int status;
-
-	conn->response = CHANNEL_EIO;
-	/*
-	 * Open a curl channel, do not connect yet
-	 */
-	if (channel->open(channel, &channel_cfg) != CHANNEL_OK) {
-		return -EIO;
-	}
-
-	if (asprintf(&channel_cfg.url, "%s%s",
-			 conn->url, STATUS_URL_V1) < 0) {
-		ERROR("Out of memory.");
-		return -ENOMEM; 
-	}
-
-	/* Retrieve last message */
-	conn->response = channel->get(channel, (void *)&channel_cfg);
-
-	if (conn->response != CHANNEL_OK) {
-		status = -EIO;
-		goto cleanup;
-	}
-
-	/* Retrieve all fields */
-	status = -EBADMSG;
-	if (!(json_data = parse_reqstatus(channel_cfg.json_reply,
-					(const char *[]){"Status", NULL})))
-		goto cleanup;
-	status = json_object_get_int(json_data);
-
-	if (!(json_data = parse_reqstatus(channel_cfg.json_reply,
-					(const char *[]){"Msg", NULL})))
-		goto cleanup;
-	const char *msg = json_object_get_string(json_data);
-
-	if (!(json_data = parse_reqstatus(channel_cfg.json_reply,
-					(const char *[]){"LastResult", NULL})))
-		goto cleanup;
-	int lastResult = json_object_get_int(json_data);
-
-	if (strlen(msg) > 0)
-		conn->gotMsg = (strlen(msg) > 0) ? true : false;
-
-	if (!ignore) {
-		if (strlen(msg)) {
-			TRACE("Update to %s :  %s", conn->url, msg);
-		}
-		if (status == IDLE) {
-			TRACE("Update to %s : %s", conn->url, 
-				(lastResult == SUCCESS) ? "SUCCESS !" : "FAILURE");
-		}
-	}
-
-	*result = lastResult;
-
-cleanup:
-	free(channel_cfg.url);
-	channel->close(channel);
-	free(channel);
-
-	return status;
-}
-
 static int retrieve_msgs(struct hnd_priv *priv) {
 	struct curlconn *conn;
 	int ret;
@@ -432,32 +342,6 @@  static int install_remote_swu(struct img_type *img,
 		conn->total_bytes = img->size;
 		conn->SWUpdateStatus = IDLE;
 
-		/*
-		 * Try to connect to check Webserver Version
-		 * If there is an anwer, but with HTTP=404
-		 * it is V2
-		 * Just V2 is supported (TODO: support older versions, too ?)
-		 */
-
-		ret = get_answer_V1(conn, &conn->SWUpdateStatus, true);
-		if (ret < 0 && (conn->response == CHANNEL_ENOTFOUND)) {
-			conn->ver = SWUPDATE_WWW_V2;
-		} else if (!ret) {
-			conn->ver = SWUPDATE_WWW_V1;
-		} else {
-			ERROR("Remote SWUpdate not answering");
-			ret = FAILURE;
-			goto handler_exit;
-		}
-		TRACE("Found remote server V%d",
-			conn->ver == SWUPDATE_WWW_V2 ? SWUPDATE_WWW_V2 : SWUPDATE_WWW_V1);
-
-		if (conn->ver == SWUPDATE_WWW_V1) {
-			ERROR("FAULT: there is no support for older website");
-			ret = FAILURE;
-			goto handler_exit;
-		}
-
 		/*
 		 * Create one FIFO for each connection to be thread safe
 		 */
diff --git a/handlers/swuforward_handler.h b/handlers/swuforward_handler.h
index f770ca0..865fabf 100644
--- a/handlers/swuforward_handler.h
+++ b/handlers/swuforward_handler.h
@@ -19,9 +19,7 @@ 
  */
 #define CUSTOM_HEADER "X_FILENAME: "
 #define MAX_WAIT_MS	3000
-#define POST_URL_V1	"/handle_post_request"
 #define POST_URL_V2	"/upload"
-#define STATUS_URL_V1	"/getstatus.json"
 
 /*
  * The handler checks if a remote update was successful
@@ -33,11 +31,6 @@ 
 #define TIMEOUT_GET_ANSWER_SEC		900	/* 15 minutes */
 #define POLLING_TIME_REQ_STATUS		50	/* in mSec */
 
-typedef enum {
-	SWUPDATE_WWW_V1 = 1,
-	SWUPDATE_WWW_V2 = 2,
-} SWUPDATE_WEB_VER;
-
 typedef enum {
 	WS_UNKNOWN,
 	WS_ESTABLISHED,
@@ -59,7 +52,6 @@  struct curlconn {
 	size_t total_bytes;	/* size of SWU image */
 	int fifo[2];		/* Pipe for IPC */
 	char *url;		/* URL for forwarding */
-	SWUPDATE_WEB_VER ver;	/* version of remote Webserver (V1 or V2) */
 	bool gotMsg;		/* set if the remote board has sent a new msg */
 	RECOVERY_STATUS SWUpdateStatus;	/* final status of update */
 	channel_op_res_t response;