Skip to content

Commit 40185f3

Browse files
TaeheeYooPaolo Abeni
authored andcommitted
amt: drop unexpected advertisement message
AMT gateway interface should not receive unexpected advertisement messages. In order to drop these packets, it should check nonce and amt->status. Fixes: cbc21dc ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 627f169 commit 40185f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/amt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,10 @@ static bool amt_advertisement_handler(struct amt_dev *amt, struct sk_buff *skb)
22602260
ipv4_is_zeronet(amta->ip4))
22612261
return true;
22622262

2263+
if (amt->status != AMT_STATUS_SENT_DISCOVERY ||
2264+
amt->nonce != amta->nonce)
2265+
return true;
2266+
22632267
amt->remote_ip = amta->ip4;
22642268
netdev_dbg(amt->dev, "advertised remote ip = %pI4\n", &amt->remote_ip);
22652269
mod_delayed_work(amt_wq, &amt->req_wq, 0);
@@ -2975,6 +2979,7 @@ static int amt_dev_open(struct net_device *dev)
29752979

29762980
amt->req_cnt = 0;
29772981
amt->remote_ip = 0;
2982+
amt->nonce = 0;
29782983
get_random_bytes(&amt->key, sizeof(siphash_key_t));
29792984

29802985
amt->status = AMT_STATUS_INIT;

0 commit comments

Comments
 (0)