forked from lei.chen/myxce
feat(config-repl): wire handle_upgrade_config() via raw packet interception
Pre-decode opcode peek in myreq_handler() captures raw packet bytes for OP_upgradeConfig before xce_decode() frees the capnp segment. Passes raw bytes to xce_upgrade_config_req_extract_raw() to extract sha256 and config blob, then delegates to do_upgrade_config_with_bytes(). Removes Task 11 dependency. Phase 2 still gated by CONF_ENABLE_UPGRADE_CONFIG.
This commit is contained in:
parent
2aae45f046
commit
5053c8d42f
3 changed files with 66 additions and 27 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "cluster.h"
|
||||
#include "config_repl.h"
|
||||
#include "controller.capnp.h"
|
||||
#include "dataq.h"
|
||||
#include "htab.h"
|
||||
#include "kvmgr.h"
|
||||
|
|
@ -158,6 +159,32 @@ static int myreq_handler(vtask_t* task)
|
|||
xce_request_t request;
|
||||
xce_reply_t reply;
|
||||
|
||||
/* Peek at opcode to decide whether to save raw bytes before xce_decode()
|
||||
* frees the capnp segment. OPCode_upgradeConfig requires the raw packet
|
||||
* for xce_upgrade_config_req_extract_raw(). */
|
||||
uint8_t *raw_pkt_copy = NULL;
|
||||
size_t raw_pkt_sz = 0;
|
||||
{
|
||||
io_packet_t *pkt = data->u.iodata.pkt;
|
||||
if (pkt && pkt->data && pkt->sz > 0) {
|
||||
struct capn peek_c;
|
||||
struct Request peek_rq;
|
||||
Request_ptr peek_rp;
|
||||
capn_init_mem(&peek_c, (const uint8_t *)pkt->data, (size_t)pkt->sz, 0);
|
||||
peek_rp.p = capn_getp(capn_root(&peek_c), 0, 1);
|
||||
read_Request(&peek_rq, peek_rp);
|
||||
capn_free(&peek_c);
|
||||
|
||||
if (peek_rq.opcode == OPCode_upgradeConfig) {
|
||||
raw_pkt_copy = (uint8_t *)malloc((size_t)pkt->sz);
|
||||
if (raw_pkt_copy) {
|
||||
memcpy(raw_pkt_copy, pkt->data, (size_t)pkt->sz);
|
||||
raw_pkt_sz = (size_t)pkt->sz;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rc = xce_decode(data->u.iodata.pkt, &request);
|
||||
|
||||
TRACE("%s cpu#%d opcode %s", __func__, task->vcpu,
|
||||
|
|
@ -233,7 +260,7 @@ static int myreq_handler(vtask_t* task)
|
|||
rc = -EAGAIN;
|
||||
break;
|
||||
}
|
||||
rc = handle_upgrade_config(c, ep, &request);
|
||||
rc = handle_upgrade_config(c, ep, &request, raw_pkt_copy, raw_pkt_sz);
|
||||
break;
|
||||
#else
|
||||
{
|
||||
|
|
@ -257,6 +284,7 @@ static int myreq_handler(vtask_t* task)
|
|||
}
|
||||
|
||||
free_Request(&request);
|
||||
free(raw_pkt_copy); /* NULL-safe: free(NULL) is a no-op */
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue