Skip to content

Commit

Permalink
Merge pull request #309 from wumiaont/master
Browse files Browse the repository at this point in the history
Why I did it
It is found that if I run gnmi subscribe to db change with an invalid xpath, gnmi server has a panic because of nil pointer dereference.

Test is against multi-asic chassis. In telemtery test test_on_change_updates is did not handle the multi-asic properly which sends out gnmi subscribe like this: python /root/gnxi/gnmi_cli_py/py_gnmicli.py -g -t 10.250.6.233 -p 50052 -m subscribe -x NEIGH_STATE_TABLE -xt STATE_DB -o ndastreamingservertest --subscribe_mode 0 --submode 1 --interval 0 --update_count 2 --create_connections 1

gnmi container restarts with a panic.

Correct CLI commands should be: python /root/gnxi/gnmi_cli_py/py_gnmicli.py -g -t 10.250.6.233 -p 50052 -m subscribe -x NEIGH_STATE_TABLE/asic0 -xt STATE_DB -o ndastreamingservertest --subscribe_mode 0 --submode 1 --interval 0 --update_count 2 --create_connections 1

How I did it
Fix the deference of nil pointer with this scenario.
  • Loading branch information
rlhui authored Nov 22, 2024
2 parents e6bc0e7 + 80067ec commit d77883d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gnmi_server/client_subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,13 @@ func (c *Client) Run(stream gnmipb.GNMI_SubscribeServer) (err error) {
/* For any other target or no target create new Transl Client. */
dc, err = sdc.NewTranslClient(prefix, paths, ctx, extensions, sdc.TranslWildcardOption{})
}
defer dc.Close()

if err != nil {
return grpc.Errorf(codes.NotFound, "%v", err)
}

defer dc.Close()

switch mode {
case gnmipb.SubscriptionList_STREAM:
c.stop = make(chan struct{}, 1)
Expand Down

0 comments on commit d77883d

Please sign in to comment.